Javascript 带mongodb设计的Sails.js

Javascript 带mongodb设计的Sails.js,javascript,php,mongodb,model-view-controller,sails.js,Javascript,Php,Mongodb,Model View Controller,Sails.js,刚刚启航 目前我已经建立了一个用户模型。我还有另一个创始人模型来存储特定于也是模型的用户的信息 attributes: { companyName: { type: 'string', required: true }, tagLine: { type: 'string', required: true }, location: { type: 'string',

刚刚启航

目前我已经建立了一个用户模型。我还有另一个创始人模型来存储特定于也是模型的用户的信息

attributes: {
    companyName: {
        type: 'string',
        required: true
    },

    tagLine: {
      type: 'string',
      required: true
    },

    location: {
        type: 'string',
        required: true
    },

    market: {
        type: 'string',
      required: true
    }, 

    psName: {
      type: 'string',
      required: true
    },

    psDesc: {
      type: 'string'.
      required: true
    }
}
所以我在FounderController中的问题是…从数据库的用户输入用户的唯一id是在模型中还是在控制器中实现的?创始人模型将基本上创建自己的唯一id

我的第一种方法基本上是从用户文档中找到ID,将其存储到变量中,用用户ID更新创始人文档的ID字段


我觉得这不是很有效。谢谢

我不确定我是否完全遵循了这一点,但听起来你只是想在两个模型及其数据之间创建一个引用。您可以使用以下用户:{model:'user'}执行此操作,然后在创建传递给该用户的项时,该项应附加到该项。在查询以获取引用对象时,还可以签出“填充”函数。如果我不了解你想要的,请告诉我。我不确定我是否完全遵循了这一点,但听起来你只是想在两个模型及其数据之间创建一个引用。您可以使用以下用户:{model:'user'}执行此操作,然后在创建传递给该用户的项时,该项应附加到该项。在查询以获取引用对象时,还可以签出“填充”函数。如果我离你要找的东西很远,请告诉我。