问题
I'm using sails for my latest project, and would like to query a model for items that do not have an association. For example
title collection...
[
{
id : 1,
name : "ABC123",
media : 1
},
{
id : 2,
name : "DEF456"
}
]
media collection...
[
{
id : 1,
name : "1234.mpg",
title : 1
},
{
id : 2,
name : "5678.mpg"
}
]
So, you can see that title 1 is associated (one to one) with media 1, and visa-versa, and that title 2, and media 2 are not associated with anything.
My question is, using the waterline query language, can I query for items that do not have an association, or more simply, do not have a specific key.
edit: Thanks to @jperezov, turns out, it's the sails-disk shortcomings, and when using sails-mongo, the following actually works.....
{
"where" : {
"media" : null
}
}
回答1:
That's simply an issue with Sails-Disk. At the current version (0.10.9 at the time of this writing), Sails-Disk doesn't support all the features of a standard database.
Change your database connection to a standard redis / sql / nosql DB, and your
{
"where" : {
"media" : null
}
}
statement should work.
来源:https://stackoverflow.com/questions/35320904/sails-waterline-where-association-not-exist