Questions tagged [subdocument]

Concept in document-oriented databases, where a field in document is a document in itself.

Concept in document-oriented databases, where a field in document is a document in itself.

Example document as JSON, where address is a subdocument:

{
    name: "Snake",
    address: {
       street: "742 Evergreen Terrace",
       city: "Springfield"
    }
}
288 questions
0
votes
1 answer

check if number exists in subdocument with Mongoose

I have a document which looks like: var User = new Schema({ _id: ObjectId, name: String, position: [{ _id:ObjectId, index_number:Number, preference:[{ candidate_id:…
user
  • 395
  • 2
  • 11
  • 28
0
votes
1 answer

remove all from subdoocument with mongoose/mongodb

I have a collection: var mongoose = require('mongoose'); var Schema = mongoose.Schema; ObjectId = Schema.ObjectId; var User = new Schema({ id: ObjectId, name: String, positionsApplied:[{ position_id:ObjectId, …
user
  • 395
  • 2
  • 11
  • 28
0
votes
1 answer

mongoose modify multi level subdocument then save not work normally

I have a Torrent item, it has subdocument array named '_replies' to saved user comments, and every comment also include subdocument array '_replies' to saved user reply, this is my all schema define: var CommentSchema = new Schema({ user: { …
taobataoma
  • 19
  • 1
  • 7
0
votes
0 answers

Insert into subdocument with Mongoose

I currently have a schema: var User = new Schema({ id: String, position: [{ _id:String, title: String, location: String, start: String, term:Number, description:String, …
user
  • 395
  • 2
  • 11
  • 28
0
votes
1 answer

Insert array into MongoDB subdocument with Node.js

I currently have a schema which looks as follows: positionsApplied:[{ position_id:String, index_position: Number }], I also have 3 objects which I need to insert into my database: How can I insert these into my database through an…
user
  • 395
  • 2
  • 11
  • 28
0
votes
1 answer

Restheart query for an nested array subdocument

I m working with mongodb and restheart. In my nosql db i have a unique document with this structure: { "_id": "docID", "users": [ { "userID": "12", "elements": [ { …
Alex
  • 1,515
  • 2
  • 22
  • 44
0
votes
0 answers

return subdocuments from array of id's with mongoose

I currently have an array of multiple id's which reference subdocuments. What I need to do is search collections for these Id's and return the information associated with them. var ids…
user
  • 395
  • 2
  • 11
  • 28
0
votes
1 answer

how to update subdocument mongodb

Here is my collection: { "_id" : ObjectId("58d32e3c8726e31b00004ac9"), "buyer" : "zul@buyer1001", "sellers" : [ { "seller" : "razi@seller1001", "items" : [ { …
0
votes
0 answers

Update / create subdocument in array

I got a data like this in my User collection on my MongoDB database { "_id" : ObjectId("5890a9598c36d45435d521c7"), "name" : "Test Testsson", "email": "test@test.com," "tasks": [{ "_id" :…
Goran
  • 1,002
  • 3
  • 14
  • 29
0
votes
1 answer

Skip one nested level of subdocument in Mongoose

I have a parent schema with a subdocument. The subdocument has a property with an array of embedded objects: Child schema var snippetSchema = new Schema({ snippet: [ { language: String, text: String, …
unitario
  • 6,295
  • 4
  • 30
  • 43
0
votes
1 answer

In Mongo query in Subdocuments multiple fields

I have a collection in Mongo { "_id": 1, "favorites": { "artist": "Picasso", "food": "pizza" }, "finished": [ 17, 3 ], "badges": [ "blue", "black" ], "points": [ { "points": 85, "bo nus": 20 …
0
votes
2 answers

Get a document with only sub documents matching a criteria with mongoose

I have this mongoose model: var mySubEntitySchema = new Schema({ property1: String, property2: String }); var myEntitySchema = new Schema({ name: String, sub: [mySubEntitySchema] }); export var MyEntityModel:…
0
votes
1 answer

Pushing sub-sub-document to array with mongoose

I have schemas countrySchema and citySchema citySchema = { cityName: String, schools: [schoolSchema] } countrySchema = { countryName: String, cities: [citySchema] } I want to push a school to the schools array in the city schema. I already…
Jamgreen
  • 10,329
  • 29
  • 113
  • 224
0
votes
2 answers

Retrieve Array in Subdocument MongoDB

I have a Users model structure somewhat like this: const userSchema = new mongoose.Schema({ email: { type: String, unique: true }, password: String, todosDo: [models.Do.schema], } And the child "Do" schema somewhat like this (in a different…
0
votes
1 answer

Get one Array of objects mongodb

I have many sub documents in my collection, I only want to fetch Configuration array of objects (not empty) and ignore all others object I tried one of the solution on stackoverflow Find MongoDB records where array field is not empty (using…