问题标签 [waterline]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
mysql - SailsJS - How to specify string attribute length without getting error when creating record?
I'm using Sails 0.9.8 paired with MySQL and wanting to do something like this
instead of
So I put something like this in the model:
But I've got an error whenever I run sails lift:
So after I run through the modules, I discovered that it was because by default Sails give string-type attribute a length of 255 in the database. The given length can be overridden with 'size', but it causes another error when creating a record.
The error caused when creating a record:
The question is, how do I specify the size of the string column (so that I can use the unique key) without getting an error when creating a record?
node.js - 如何使用sailsjs在MongoDb中存储和检索图像?
如何为以下定义存储图像的模型
“图像”类型应该是什么以及如何存储图像?
如何使用“人”模型存储和更新图像?
angularjs - 如何使用 MEAN 和sails.js 开始一个新项目
我过去用 node.js、express 和 angular.js 创建了一个 Web 应用程序。我正在开始一个新项目,我也想使用 MongoDB。那将是 MEAN 堆栈。仅使用 MEAN,我可以使用以下内容开始一个项目: http: //mean.io/。
现在,我过去曾编写过 REST API,并且听说过sails.js,这听起来非常引人注目。它可以自动为您创建 REST API。
所以我的问题是,我将遵循哪些步骤来使用 MEAN 堆栈和sails.js 开始一个新项目?
选项:
- 我会克隆 mean.io 堆栈,运行 npm install 然后再运行 npm installsails.js 吗?
- 或者,sails.js 似乎对如何处理目录结构有自己的想法。那么我会按照他们的说明安装sails.js吗http://sailsjs.org/#!getStarted然后 npm install Angular 和 Mongo?(我认为我不需要 Mongoose,因为sails.js 有自己的 ORM,水线)。
我今天实际上要尝试选项 2,但我很高兴知道哪些步骤对其他人有用。
非常感谢!
node.js - Sailsjs:如何在*更新*模型后填充关联?
我有以下适用于index、show、create方法的控制器代码,但是当我包含 populate 时更新失败 - 我做错了什么?
javascript - 有没有办法在sails.js 中禁用水线并使用不同的ORM?
我想在我的sails.js应用程序中用猫鼬替换水线。我正在寻找正确的方法来做到这一点,但我看不到文档中的方法。谁能解释如何做到这一点?
sails.js - Sailsjs 数组查询精确匹配
我想在sailsjs 中查询mongodb。这是我的数据库的结构
我想搜索那些匹配数组的“用户”
pre>Message.find({用户: ["52ed09e1d015533c124015d5","52ed4bc75ece1fb013fed7f5"]})此查询返回包含 1 OR 2 的所有对象 ..但我只需要那些完全匹配 1 和 2 的对象,我也尝试过 $all 等。但没有奏效请告诉我如何使用sailsjs 支持的语法编写查询让那些用户
node.js - Sails.js & MongoDB:重复键错误索引
我正在使用 Sails.js (0.9.8) 和 MongoDB(通过sails-mongo 适配器)来创建可以定位在树视图中的页面集合。我想将页面的路径存储在 UUID 数组中
我的模型:
当我保存“根”页面时效果很好(“路径”属性只有一项,因为它是根页面。这是它保存在 MongoDB 中的内容:
但是当我想在我之前创建的页面(主页/产品)下面创建一个“子页面”时,我收到了这个错误:
MongoError:E11000 重复键错误索引:cms-project.item.$path_1 重复键:{:“a2b23e1f-954b-49a3-91f1-4d62d209a093”}
这是我发送的数据:
我可能错过了一些东西,但我不知道是什么。如果我将路径存储在字符串而不是数组中,它工作得很好,但我发现它不那么优雅和方便。
javascript - MongoDB 发现 $in 在sails.js 中不起作用
我正在使用 Sail.js 及其 Waterline ORM 创建一个简单的应用程序。作为其中的一部分,我遵循 NoSQL 等效的数据透视表模式:每个用户都有一个数组,subscriptions
包含他们订阅的所有频道。我正在尝试使用以下命令查找订阅特定频道 ID 的所有用户:
不是每个编写的最漂亮的代码行,但它应该可以工作。问题是,它没有。users
是一个空数组,并且err
为空。他们查询实际执行的是,例如(使用节点检查器):
当通过 umongo GUI 使用相同的查询“查找”用户时,它可以正常工作。但是,执行该函数时,没有找到任何用户。
和想法?谢谢!
javascript - Sails 如何将数组中的字符串类型转换为 json
我在 Sails 中构建了一个简单的 REST 应用程序,我想将正确的数据保存在 type 的模型属性中array
。
发帖路线
http://localhost:1337/locations/create?name=savassibeer&locations={latitude:23789472398.2344,longitude:2734637892.56756756}&locations={latitude:22.2344,longitude:2562.56756756,date:2014-02-15T11:00:00}
结果
如何将字符串转换locations
为有效的 JSON 对象并保存?
javascript - 如何在 Waterline ORM 中设置数据库连接字符串
我刚刚从 npm 下载了 Waterline。我有一些文件夹,但找不到我在哪里可以设置主机/用户/密码等来连接我的 postgress 数据库。我看了水线文件夹中的所有文件,什么也没有。谁能告诉我在哪里设置?