Beacon model:
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const Beacon = sequelize.define('Beacon', {
id: {
type: DataTypes.INTEGER,
field: 'ID',
primaryKey: true,
autoIncrement: true
},
talentQueueId: {
type: DataTypes.INTEGER,
field: 'TalentQueueID',
},
createdAt: {
type: DataTypes.DATE,
defaultValue: Sequelize.literal('now()')
},
updatedAt: {
type: DataTypes.DATE,
defaultValue: Sequelize.literal('now()')
},
deletedAt: {
type: DataTypes.DATE
}
}, {
tableName: 'Beacon',
schema: process.env.DATABASE_SCHEMA
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
Beacon.associate = models => {
Beacon.belongsTo(models.TalentQueue, {
foreignKey: {
name: 'talentQueueIdKey',
field: 'TalentQueueID',
},
target: {
name: 'ID',
field: 'ID',
},
as: 'TalentQueue',
});
};
return Beacon;
};
TalentQueue model
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const TalentQueue = sequelize.define('TalentQueue', {
id: {
type: DataTypes.INTEGER,
field: 'ID',
primaryKey: true,
autoIncrement: true
},
createdAt: {
type: DataTypes.DATE,
defaultValue: Sequelize.literal('now()')
},
updatedAt: {
type: DataTypes.DATE,
defaultValue: Sequelize.literal('now()')
},
deletedAt: {
type: DataTypes.DATE
}
}, {
tableName: 'TalentQueue',
schema: process.env.DATABASE_SCHEMA
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
TalentQueue.associate = models => {
TalentQueue.hasMany(models.Beacon, {
foreignKey: {
name: 'talentQueueIdKey',
field: 'TalentQueueID'
},
target: {
name: 'ID',
field: 'ID'
},
as: 'Beacon'
});
TalentQueue.hasMany(models.TalentQueuexUser, {
foreignKey: {
name: 'TalentQueueID',
field: 'TalentQueueID'
},
sourceKey: 'id',
as: 'TalentQueuexUsers'
});
TalentQueue.belongsToMany(models.User, {
as: 'Users',
through: 'TalentQueuexUser',
foreignKey: 'TalentQueueID',
otherKey: 'UserID'
});
};
return TalentQueue;
};
TalentQueuexUser model:
const TalentQueuexUser = sequelize.define('TalentQueuexUser', {
id: {
type: DataTypes.INTEGER,
field: 'ID',
primaryKey: true,
autoIncrement: true
},
userId: {
type: DataTypes.INTEGER,
field: 'UserID'
},
talentQueueId: {
type: DataTypes.INTEGER,
field: 'TalentQueueID'
},
createdAt: {
type: DataTypes.DATE,
defaultValue: Sequelize.literal('now()')
},
updatedAt: {
type: DataTypes.DATE,
defaultValue: Sequelize.literal('now()')
},
deletedAt: {
type: DataTypes.DATE
}
}, {
tableName: 'TalentQueuexUser',
schema: process.env.DATABASE_SCHEMA
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
TalentQueuexUser.associate = models => {
TalentQueuexUser.belongsTo(models.TalentQueue, {
as: 'TalentQueue',
foreignKey: {
name: 'TalentQueueID',
field: 'TalentQueueID'
},
target: {
name: 'ID',
field: 'ID'
}
});
TalentQueuexUser.belongsTo(models.User, {
foreignKey: {
name: 'UserID',
field: 'UserID'
},
target: {
name: 'ID',
field: 'ID'
},
as: 'User'
});
};
return TalentQueuexUser;
};
Using the typical @record
and @each
pattern:
No length in the ember data object:
No length in the smart view query fetch:
the talent queue shows associated users: