You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.
One way to do this is to generate the Ids outside of the config, for example:
var ObjectID = require('mongodb').ObjectID;
var vadorId = new ObjectID();
var skywalkerId = new ObjectID();
module.exports.seed = {
person: [
{
id: skywalkerId,
firstName: 'Luke',
lastName: 'Skywalker',
nemesis: vadorId
},
{
id: vadorId,
firstName: 'Darth',
lastName: 'Vader',
nemesis: skywalkerId
}
]
}
But the above solution is not ideal because the Id generation in this case is tied to mongo, and if we switched to SQL for example we'd need to refactor this (not very Waterline).
Thoughts?
The text was updated successfully, but these errors were encountered:
Love your example by the way (nemesis). I hadn't even though of referencing ids. That makes total sense, any type of relational db would have them, and even nosql dbs at least of the referencing ability. I will definitely check this out over the weekend and let you know what I come up with, but this is definitely a good add on.
@facultymatt@arca223 this is now I believe a completely necessary feature and I'll be working on this this week and should have the new version out next week with this possiblity
Lets say you want to know the id of an object you've seeded to reference on another object.
One way to do this is to generate the Ids outside of the config, for example:
But the above solution is not ideal because the Id generation in this case is tied to mongo, and if we switched to SQL for example we'd need to refactor this (not very Waterline).
Thoughts?
The text was updated successfully, but these errors were encountered: