不存在关联的帆/水线 [英] sails/waterline where association not exist

查看:36
本文介绍了不存在关联的帆/水线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的最新项目中使用了风帆,并且想要查询没有关联的项目的模型.例如

标题集...

<预><代码>[{编号:1,名称:ABC123",媒体:1},{编号:2,名称:DEF456"}]

媒体收藏...

<预><代码>[{编号:1,名称:1234.mpg",标题 : 1},{编号:2,名称:5678.mpg"}]

因此,您可以看到标题 1 与媒体 1 相关联(一对一),反之亦然,并且标题 2 和媒体 2 与任何内容都没有关联.

我的问题是,使用水线查询语言,我可以查询没有关联的项目,或者更简单地说,没有特定键的项目.

感谢@jperezov,事实证明,这是sails-disk的缺点,当使用sails-mongo时,以下实际上有效.....

<代码>{在哪里" : {媒体":空}}

解决方案

这只是 Sails-Disk 的一个问题.在当前版本(撰写本文时为 0.10.9),Sails-Disk 不支持标准数据库的所有功能.

将您的数据库连接更改为标准的 redis/sql/nosql DB,然后您的

<代码>{在哪里" : {媒体":空}}

语句应该有效.

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
    }
}

解决方案

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.

这篇关于不存在关联的帆/水线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆