在SailsJS 1.0模型中定义一个数组

问题描述 投票:1回答:1

我们一直在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]}
  },

帆支持的类型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

有没有人对此有任何想法?

sails.js waterline
1个回答
1
投票

你可以像这样使用它:

'coordinate': {
      'type': 'json',
      'required': true,
    },

或者您可以像这样使用它:

'cost_price': {
      'type': 'ref',
      'columnType': "double"

    },

colunmType中,您可以定义数据库列类型

© www.soinside.com 2019 - 2024. All rights reserved.