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
2 answers

Search Specific Element In array mongodb

I am trying to find a specific object from array of objects in mongodb. I am trying this Company.findOne ({ "configuration.macAddress": "AB-90-dF-8d" }); It returns me the exact company but it returns all the configuration array I want only…
0
votes
1 answer

Mongoose insert subdocument in another subdocument

I need insert in a subdocument another subdocument I have seen some examples, but they only have a reach to the first level of subdocument this is my model var mongoose = require('mongoose'); var Schema = mongoose.Schema; var Infonodo =…
0
votes
2 answers

moongose nested subdocument update and delete

"_id": { "$oid": "577cc50d10b5a6c42b26f414" }, "firstName": "new", "lastName": "new", "__v": 0, "A": [ { "AfirstName": "AfirstName", "AlastName": "AlastName", "_id": { "$oid":…
0
votes
1 answer

How to count and paginate subdocument which is an object in mongodb

I have data saved in the following: { "_id" : ObjectId("57723b5e009793e8f3cfd1d7"), "room" : "1003", "inout" : { "1" : [ "i1654", "o1656", "i1706", "o1707", ], …
0
votes
1 answer

Mongoose search for an object's value in referenced property (subdocument)

I have two schemas: var ShelfSchema = new Schema({ ... tags: [{ type: Schema.Types.ObjectId, ref: 'Tag' }] }); var TagSchema = new Schema({ name: { type: String, unique: true, required: true …
danielemm
  • 1,636
  • 1
  • 14
  • 24
0
votes
1 answer

How to search for a match on values in whle document and all subdocuments in MongoDB?

I have a mongo database with a collection named store. db.store.find() on mongo shell yields the below. { "_id" : ObjectId("575d6fab0cde6714290f444f"), "train" : "a", "data" : { "0" : { "this" : 21, "that" : 31, "value" : 11, "month" : 1 }, "3" : {…
Gaumire
  • 255
  • 2
  • 8
0
votes
0 answers

MongoDB aggregation: Replacing sub-document with a value out from it

Let's say I have a collection of documents in the following format: { // some fields "name" : "some name", "specs" : [ { "key" : { "en" : "English key name", "xx" : "Other key name", …
RIscRIpt
  • 163
  • 3
  • 12
0
votes
1 answer

Updating a mongoose sub-document modifies the original schema

I'm trying to store the location of a parking Spot in a single embedded sub-document for a cleaner object model. I want to have the coordinates of a location for a Spot default to [] for every new Spot. When I create a Schema as follows: var…
Nigh7Sh4de
  • 395
  • 2
  • 7
  • 20
0
votes
2 answers

Mongoose ValidationError Path required that is out of subdocument array bounds

This error is super wacky. It doesn't always fail, but when it does it looks like this. I have some code that changes the "code" (a one character string) of elements in a subdocument array. It goes through each goal, checks to see if there's a…
MalcolmOcean
  • 2,807
  • 2
  • 29
  • 38
0
votes
0 answers

Create output as parent-child from list of documents based on subdocuments

I have record in database as below (http://www.jsoneditoronline.org/?id=cb05d8495014d3581acaf3fa466d5e4c) [{ "X" : "ValueofX", "Y" : "ValueofY", "_id" : ObjectId("XXX"), "controlprops" : { …
maulik sakhare
  • 1,957
  • 1
  • 12
  • 19
0
votes
1 answer

Wrong reference in Spring MongoDB data aggregation

I have mongodb documents of following kind: { "_id" : { "refId" : ObjectId("55e44dd70a975a6fec7ae66e"), "someString" : "foo" }, "someValue" : 1, "date" : NumberLong("1441025536869"), "subdoc" : { "someRef" :…
0
votes
1 answer

How can I omit elements from arrays inside nested documents with mongo?

I have the following structure for a collection in MongoDB { '_id': 45 'tags': [ 'tag 1', 'tag 3' ] 'active': true 'fields': [ { 'name': 'common field 1', 'type': 'text', 'value': 'some text', ... }, { 'name': 'common field…
Clara Daia
  • 149
  • 1
  • 1
  • 7
0
votes
0 answers

How to 'skip' and 'include' subdocuments with mongoose query

Let's say I have this structure Account { Id, Name, Password, Details { LastSignedIn, CreatedDate Address { City, …
Sergino
  • 10,128
  • 30
  • 98
  • 159
0
votes
1 answer

MongoDB unique index across multiple subdocuments

I have this document structure, the property "Name" must be unique across all documents, as shown above: { "_id" : ObjectId("56686341d6389c004c689d5d"), "Bosses" : { "B1" : { "_id" : NumberInt(1), "Name" :…
0
votes
1 answer

Mongoose find in array of referenced subdocuments

I am trying to find certain visits coming from an ip.The visits schema looks like this : var VisitSchema = new Schema({ visitId: String, ip: [{ type: Schema.Types.ObjectId, ref: 'VisitorIp' }] }); mongoose.model('Visit',…