Skip to content

Instantly share code, notes, and snippets.

@kmiyashiro
Created March 10, 2012 22:17
Show Gist options
  • Save kmiyashiro/2013589 to your computer and use it in GitHub Desktop.
Save kmiyashiro/2013589 to your computer and use it in GitHub Desktop.
Upsert nested array/objects possible?
I have a schema that looks like this:
band: {
albums: [
{ tweets: [
{ tweet }, { tweet }
] }
]
}
I want to add the band (doc) if it doesn't exist.
I want to add the album if it doesn't exist on the band
I want to add the tweet to the album if it doesn't exist
Do I just do each of these serially or is there a way to upsert?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment