sails/waterline where association not exist

好久不见. 提交于 2020-01-07 03:04:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!