javascript - Sails.js 1.0 的嵌套属性 where 子句不再起作用

标签 javascript mongodb sails.js waterline

我刚刚升级到 Sails.js 1.0,我的装饰器模式停止工作。

这就是我所拥有的:

let model = Model.find()

model
  .where({
    'nested.property': {
      '>': 1
    }
  })

model.exec()

给我:

Could not use the provided where clause. Could not filter by nested.property: nested.property is not a valid name for an attribute in Waterline. Even though this model (model) declares schema: false, this is not allowed.

我的数据库是 MongoDB。

最佳答案

这是一个未记录的功能,不再起作用。完整引用如下:

it looks like you were relying on some undocumented features of Waterline that just happened to work in previous versions; namely using native Mongo query syntax within a Waterline query. In 1.0, you'll need to use the lower-level datastore functionality.

Source

我最终使用了mquery它支持点表示法(例如 nested.property)。

关于javascript - Sails.js 1.0 的嵌套属性 where 子句不再起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44737352/

相关文章:

javascript - 如何在 Sails js (nodejs MVC) 中使用外部 rest api

javascript - 全局安装 Sails.js 出现依赖错误

javascript - Sails.js - 一对多映射

java - mongodb 中 spring 数据的 json 响应中缺少 id

c# - 使用具有鉴别器和多态性的 C# MongoDB v2 驱动程序

node.js - mongodb 中填充的替代方案?

javascript - $.ajaxFileUpload 成功将文件上传到文件夹,但无法传递要保存在数据库中的值

javascript - 为什么结果不同(使用 var 与 let)?

javascript - 使用 Apache Cordova for Visual Studio 进行身份验证

javascript - 以不区分大小写的方式反序列化 JSON 的好方法