Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature save Embedded Docs as hash/object ?? #5898

Closed
ashwintastic opened this issue Dec 12, 2017 · 5 comments
Closed

New Feature save Embedded Docs as hash/object ?? #5898

ashwintastic opened this issue Dec 12, 2017 · 5 comments
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity

Comments

@ashwintastic
Copy link

ashwintastic commented Dec 12, 2017

Do you want to request a feature or report a bug?
Feature
What is the current behavior?
Docs States that http://mongoosejs.com/docs/2.7.x/docs/embedded-documents.html You can embed a docs as an array . If one can embed a docs as json the retrieval will be faster as one doesn't has to iterate on the entire array , one can fetch data from the key .
If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

Please mention your node.js, mongoose and MongoDB version.

@vkarpov15
Copy link
Collaborator

I don't understand your suggestion, can you clarify?

@vkarpov15 vkarpov15 added the needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity label Dec 17, 2017
@ashwintastic
Copy link
Author

As per my understanding after going through mongoose-embedded-docs

    var Comments = new Schema({
            title     : String
           , body      : String
           , date      : Date
    });

 
     var BlogPost = new Schema({
           author    : ObjectId
          , title     : String
          , body      : String
          , date      : Date
          , comments  : [Comments] // can't it be {Comments}  one doesn't have to iterate if its a json
                        // if someOne have to fetch a particular comment one has to itirate
                       // over the array , if its a json one can fetch it by its key  
          , meta      : {
          votes : Number
         , favs  : Number
      }
  });

   mongoose.model('BlogPost', BlogPost);

@sobafuchs
Copy link
Contributor

sorry I still don't understand what you're asking for? DO you want to store an array or a hash/object ?

@ashwintastic
Copy link
Author

ashwintastic commented Dec 21, 2017

I want to save embedded docs as a hash/object

@ashwintastic ashwintastic changed the title New Feature save Embedded Docs as json New Feature save Embedded Docs as hash/object ?? Dec 21, 2017
@vkarpov15
Copy link
Collaborator

Mongoose currently doesn't have support for schema types with arbitrary keys (maps, hashes, etc.), follow #681 for updates. Planning on adding that in Q1 2018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity
Projects
None yet
Development

No branches or pull requests

3 participants