mongoose - acsessing data of one collection from anther module
See original GitHub issueCurrent behavior
i am using the mongoose module, lets say i have User collection which configured in the User module, Now i need this collection data in the Accounts module, i need to register it again in the Accounts module ? this is how my modules extract schemas:
Accounts Module
MongooseModule.forFeature([
{ name: 'Account', schema: AccountsSchema},
{ name: 'User', schema: UserSchema},
])
Users Module
MongooseModule.forFeature([
{ name: 'User', schema: UserSchema},
])
Is there a better way of doing it?
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (1 by maintainers)
Top Results From Across the Web
node.js - Access data from one collection to another MongoDB
You can populate the Job model and then retrieve user properties with: const job = await Job.findOne({}).populate('user').exec(); ...
Read more >How to get data from 2 different collections of mongoDB using ...
After having a model, we can use method find() on the model of a particular collection to get documents of the collection. Syntax:...
Read more >How can I insert a collection into another ... - MongoDB
I'm learning MongoDB/Mongoose by the docs and I'm trying to insert the second collection into the first collection, I know how to do...
Read more >Express Tutorial Part 3: Using a Database (with Mongoose)
This article briefly introduces databases, and how to use them with Node/Express apps. It then goes on to show how we can use...
Read more >How to Join Collections using Mongoose - ObjectRocket
This step-by-step tutorial will show you how to join collections using Mongoose and MongoDB.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Remember to export, import the modules correctly
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.