Questions tagged [embedded-documents]

95 questions
2
votes
0 answers

Is it good practice to create an index on embedded document in MongoDB?

Is it good practice to create an index on an embedded document? How does this relate to performance? Is there a noticeable real performance impact compared to a reference?
2
votes
0 answers

Get all Embedded Documents within all Documents in a Collection using MongoEngine

I've tried searching the internet for this but can't seem to find anything (sorry if this is in here somewhere). I'm using Mongoengine with Django and have the following model: class Event(EmbeddedDocument): tagged_event =…
2
votes
1 answer

Is it possible to return multiple subdocuments with mongoDB and Node.js?

I currently have a schema which currently looks like: var User = new Schema({ id: String, firstName: String, lastName: String, password: String, username: String, position: [{ title: String, location:…
user
  • 395
  • 2
  • 11
  • 28
2
votes
1 answer

How to include only selected embedded document in mongoengine?

I'm fetching documents on the base of specific EmbeddedDocument, but I don't want to get all of the EmbeddedDocuments while retrieving, only the matched EmbeddedDocument with main Document. Here's my code: School Embedded Document class…
Rohit Khatri
  • 1,980
  • 3
  • 25
  • 45
2
votes
1 answer

Auto calculating fields in mongodb

Let's say there are documents in MongoDB, that look something like this: { "lastDate" : ISODate("2013-14-01T16:38:16.163Z"), "items":[ {"date":ISODate("2013-10-01T16:38:16.163Z")}, …
dmigo
  • 2,849
  • 4
  • 41
  • 62
2
votes
1 answer

C# throws error when interpreting embedded document value of empty array []

Here is the information about my development environment: MongoDB 3.0.0 MongoDB C# Driver Version 1.7.0.4714 Microsoft Visual Studio Professional 2013 .NET Framework 4.0 Here is a C# Class whose objects will be used as embedded documents: public…
CS Lewis
  • 489
  • 8
  • 30
2
votes
1 answer

Query an array of embedded documents in mongodb

I'm having a little trouble writing a query that needs to compare a given value against a certain field in all embedded documents within an array. I will give an example to make the issue less abstract. Let's say I want to use MongoDB to store the…
zinfandel
  • 428
  • 5
  • 12
2
votes
1 answer

What does indexing a key of an embedded document really mean?

I still can't understand how indexing a key of an embedded document really works. Suppose I have the following collection of blog posts: { _id:0, author: 'John Doe', content: 'How indexing an embedded document work?', comments: …
Core_dumped
  • 1,571
  • 4
  • 16
  • 34
2
votes
0 answers

MongoDB Embedded Documents PATCH vs POST?

I would like to update an embedded document through an Api request and don't want to PUT the whole parent resource: Parent { _id: 123, ... events: [ ... ... ] } To update the embedded document, RFC 6902 A.16 suggests: PATCH…
dhudson
  • 571
  • 3
  • 9
1
vote
1 answer

mongodb does not show embedded object _id

First note: I am using @nestjs/mongoose, i don't know if the problem because @nestjs/mongoose or pure mongodb. I want to access embedded document's _id using @nestjs/mongoose. However mongoose document object does not contain embedded document's…
doruksahin
  • 332
  • 1
  • 5
  • 11
1
vote
1 answer

Mongoose getting specific item in Embedded Document

I am new in NoSQL and I'm kinda stuck. Can you help me? Is there any way to get the specific field in an array if it matches a value? For example, I would like to get the specific item in the array accountGroup where accountGroupName=="Account 1". I…
kaye_g
  • 13
  • 5
1
vote
2 answers

Project a specific field from the first element that matches the query condition on the array

I have a families collection. The documents in it have a users array. Given this family document: { "id" : "1", "users" : [ { "id" : "2", "identities" : [ { "type" :…
OzW
  • 848
  • 1
  • 11
  • 24
1
vote
1 answer

MongoDB - find count of field in nested document

I want to find the count of all occurrences of the field "36" from the the following json: The count should be 2. The field is present in any of the data.TL.TXXX documents. I tried the find() method of mongoDB, but could only search in one document…
1
vote
1 answer

MongoDB One-to-Many and Many-to-One relations in Spring Boot Project

please how can I add relations in a mongoDB cause I just start using it. For example Comment id is a foreign key: @Document class Comment { @Id private String id; private String text; private String author; …
Kindth
  • 337
  • 1
  • 8
  • 30
1
vote
1 answer

Optimized way to update large embedded array in mongo document with an indexed key

I have a user collection with 52 million records. Each user documents has a list of comments and comment_id has a unique index on it. { _id:123, user_name:"xyz", comments:[ { comment_id:123, text:"sd" }, { …