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
How can I join 2 datasets and if possible sort them?
I'd like to join the artist_id from a song to the id of the artists dataset and sort the results by artists.
My previous code, before splitting things:
Database.table.Songs.find({}).sort({ artist: 1, album: 1 }, function(err, data) { cb(data) });
The issue is that I might need to display all artists or all albums made by an artist and I think making a separate dataset for this is better.
What I would like
Database.table.Songs.find({}, function(err, data) { data.forEach(function(action) { Database.table.Artists.findOne({ _id: data.artist_id }, function (err, artist) { cb(data); }); }); });
or
Database.table.Songs.find({}).join(Database.table.Artists: {artist_id, _id}).sort({artist_name: 1}, function(err, data) { data.forEach(function(action) { Database.table.Artists.findOne({ _id: data.artist_id }, function (err, artist) { cb(data); }); }); });
Is this possible? the documentation doesn't cover this.
The text was updated successfully, but these errors were encountered:
Sounds like you’re trying to treat NeDB as a relational database (SQL) rather than a document store (NoSQL). Not recommended... wrong paradigm.
Sorry, something went wrong.
Hmm, well many NoSQL databases offer Joins ;) anyway thx
Edit: I have a db called Covers which contain images and putting this in every songs and albums would require a huge amount of disk space :\
https://www.mongodb.com/blog/post/6-rules-of-thumb-for-mongodb-schema-design-part-1
Try some of those tips... you might need a separate log style collection, but performance should be very high with simultaneous requests.
No branches or pull requests
How can I join 2 datasets and if possible sort them?
I'd like to join the artist_id from a song to the id of the artists dataset and sort the results by artists.
My previous code, before splitting things:
The issue is that I might need to display all artists or all albums made by an artist and I think making a separate dataset for this is better.
What I would like
or
Is this possible? the documentation doesn't cover this.
The text was updated successfully, but these errors were encountered: