I'm hitting a snag with my goal, wondering if anyo...
# orm-help
d
I'm hitting a snag with my goal, wondering if anyone has thoughts: I am trying to populate separate mongodb collections, from the response of an api call to twitter. My schema looks like: https://gist.github.com/marr/0b2e6a58858388df6b448f5d1d2dd879. The api response has a shape like:
{ data, includes: { media, users } }
-- the includes object includes data that may be referenced in data. The challenge is that I'm trying to create entities in the db that reference each other but don't exist yet. For example, I want to create tweets that has a media relation, but the media needs to be created first. Media also has the related tweets as part of its model. Since the tweets aren't created yet, until the media is created this presents a problem. What would be the best approach here?
When I try to call
tweet.upsert
I get an error:
Copy code
Unknown arg `author` in update.author for type TweetUncheckedUpdateInput. Did you mean `authorId`? Available args:
type TweetUncheckedUpdateInput {
  authorId?: String | StringFieldUpdateOperationsInput
  createdAt?: DateTime | DateTimeFieldUpdateOperationsInput
  entities?: Json | Json | Null
  media?: MediaUncheckedUpdateManyWithoutTweetsInput
  mediaKeys?: TweetUpdatemediaKeysInput | List<String>
  publicMetrics?: Json | Json
  text?: String | StringFieldUpdateOperationsInput
  type?: String | NullableStringFieldUpdateOperationsInput | Null
}
maybe theres no such thing as a nested update?
n
Hey David 👋 You could try creating Media first which would have no related tweets relations while creation, then refer to this media while creating tweets and also set the related tweets in media model.