Tidy, move recent documents to query scope
This commit is contained in:
@ -60,6 +60,16 @@ const Collection = sequelize.define(
|
||||
as: 'documents',
|
||||
foreignKey: 'atlasId',
|
||||
});
|
||||
Collection.addScope('withRecentDocuments', {
|
||||
include: [
|
||||
{
|
||||
as: 'documents',
|
||||
limit: 10,
|
||||
model: models.Document,
|
||||
order: [['updatedAt', 'DESC']],
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
},
|
||||
instanceMethods: {
|
||||
|
Reference in New Issue
Block a user