sails.js - 在 SailsJS 1.0 模型中定义一个数组
问题描述
我们一直在 SailsJS 0.12 上运行应用程序 - 一旦 1.0 发布,就会运行升级过程并升级
以前,一些模型支持“数组”类型,现在不再支持。有什么替代方法?它不在示例应用程序或文档中
我的模型是:
module.exports = {
attributes: {
provider: 'string',
uid: 'string',
email: 'string',
name: 'string',
firstName: 'string',
lastName: 'string',
password: 'string',
projects: {
collection: 'project',
via: 'owner'
},
creditsHistory:{
collection: 'creditsHistory',
via: 'owner'
},
userRoles: {type: 'array', defaultsTo : [roles.USER]}
},
Sails 1.0 中支持的类型是:https ://sailsjs.com/documentation/concepts/models-and-orm/attributes
没有任何关于用sails 0.12支持的类型替换数组类型的示例或示例: https ://0.12.sailsjs.com/documentation/concepts/models-and-orm/attributes
有人对此有任何想法吗?
解决方案
你可以这样使用它:
'coordinate': {
'type': 'json',
'required': true,
},
或者你可以像这样使用它:
'cost_price': {
'type': 'ref',
'columnType': "double"
},
在colunmType
您可以定义数据库列类型
推荐阅读
- c++ - c++中的异常处理错误
- crystal-reports - 将当前日期转换为第 n 个日期
- google-cloud-platform - Google Cloud 上的错误 - 基因组学:“未找到服务名称的 API 解决方案:基因组学”
- r - 当数据集在 sparklyr 中时,为什么我不能在 dplyr 中使用双冒号运算符?
- javascript - 与单击的 td 相比,如何选择第一个 td
- jquery - 根据下拉选择启用对话框按钮
- target - 比特币源代码中的矿池难度(pdiff)在哪里以及如何设置?
- c++ - 在 C++ 代码中“就地”从 C 样式字符串中删除子字符串
- android - Android Studio 无法连接到 mysql
- sql - 将多个期间分组为一个期间