Giter VIP home page Giter VIP logo

Comments (9)

daimajia avatar daimajia commented on August 23, 2024

+1

from monk.

travisjeffery avatar travisjeffery commented on August 23, 2024

We don't say that we support that api in the docs, I don't find db refs necessary really either imo.

from monk.

daimajia avatar daimajia commented on August 23, 2024

@travisjeffery Is there any convenient way to do one to many or many to many relations?

from monk.

travisjeffery avatar travisjeffery commented on August 23, 2024

@daimajia I'd do the same as this article: http://blog.markstarkman.com/blog/2011/09/15/mongodb-many-to-many-relationship-data-modeling/. Like it says in the article, you only need to use DBRef's in the array if your collection names change, in which case you could a write a migration anyway.

from monk.

daimajia avatar daimajia commented on August 23, 2024

@travisjeffery I viewed this post before. How about one to many, for example:

db.person.insert({
  "_id": ObjectId("4e54ed9f48dc5922c0094a43"),
  "firstName": "Joe",
  "lastName": "Mongo",
  "groups": [
    ObjectId("4e54ed9f48dc5922c0094a42"),
    ObjectId("4e54ed9f48dc5922c0094a41")
  ]
});

How can i quikly get the instance of the ObjectId("4e54ed9f48dc5922c0094a42") and ObjectId("4e54ed9f48dc5922c0094a41") after I do find({_id: '4e54ed9f48dc5922c0094a43'}) method using monk?
another query?

from monk.

travisjeffery avatar travisjeffery commented on August 23, 2024

Yeah another query like so:

var person; // person you have above
db.groups.find({"_id": {"$in": person.groups }});

from monk.

daimajia avatar daimajia commented on August 23, 2024

@travisjeffery I'm new to mongodb. Thanks a lot for your help. I'll have a try. :-D

from monk.

daimajia avatar daimajia commented on August 23, 2024

@travisjeffery One more question. How can I bind the db.groups.find result with the person.groups column? Do it manually using underscore?

from monk.

mathieudutour avatar mathieudutour commented on August 23, 2024

I implemented a middleware architecture and a dereferencing middleware here: https://github.com/monk-middlewares/monk-middleware-dereference

from monk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.