在Sailsjs中是否有可能构建更复杂的模型

Omi*_*emi 10 sails.js waterline

我想在我的模型中有数组或集合,这是否可以使用waterline(mongoDB)?周围有什么替代品吗?

例:

{
   name: Bundle,
   col1 : {
      name : anOtherModel,
      subCol: {
         text: aString,
         ...
      }
   },
   col2 : {
      name : anOtherModel,
      subCol: {
         text: aString,
         ...
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

至:

module.exports = {

    attributes : {

        name : {
            type : 'STRING',
            required : true
        },
        basicModules: {
            type : 'ARRAY', // or 'COLLECTION'
            required : false
        }
    }

};
Run Code Online (Sandbox Code Playgroud)

Jér*_*ker 2

如果您正在寻找模型关联,那么它还不存在(请查看此问题以获取建议的实现)如果您只想将数据数组存储在数据库中,则可以将数组作为属性(请参阅文档以获取有关那)。我还没有测试过它,但我想如果它没有匹配的结构,它会在将数组保存到数据库之前对其进行序列化。