node js:关联在sails js版本1中不起作用

yqhsw0fo  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(544)

请帮助我,我正在使用帆版本1,我想创建关联,但我得到错误。

error: A hook (`orm`) failed to load!
error: Could not tear down the ORM hook.  Error details: Error: Invalid data store identity. No data store exist with that identity.
error: Failed to lift app: { userError: The attribute `id` on the `patients` model is an association but also specifies a type property. This is not needed and will be automatically determined.

所以我有一个2模型(病人和预约),我想从预约中得到病人
//病人.js

module.exports = {
tableName: 'patients',
primaryKey: 'id',
attributes: {
    id: {
        model: 'Bookings',
        type: 'number',
        unique: true
    }
},

};
//预订.js

module.exports = {
tableName: 'booking',
attributes: {
    patient: {
        collection: 'Patients',
        via: 'id'
    }
}

};

5q4ezhmt

5q4ezhmt1#

拆下 type 财产来源 attributes 你的钥匙 Patients.js 正如错误所暗示的那样。

// Patients
module.exports = {
tableName: 'patients',
primaryKey: 'id',
attributes: {
 id: {
    type: 'number',
    unique: true
    },
 RandomAssociationName: {
    model: 'Bookings'
    }
}

// Bookings
module.exports = {
tableName: 'booking',
attributes: {
patient: {
    collection: 'Patients',
    via: 'RandomAssociationName'
  }
}

相关问题