87 lines
1.7 KiB
JavaScript
87 lines
1.7 KiB
JavaScript
const GenericDBApi = require('./base.api');
|
|
const db = require('../models');
|
|
|
|
class Project_membershipsDBApi extends GenericDBApi {
|
|
static get MODEL() {
|
|
return db.project_memberships;
|
|
}
|
|
|
|
static get TABLE_NAME() {
|
|
return 'project_memberships';
|
|
}
|
|
|
|
static get SEARCHABLE_FIELDS() {
|
|
return [];
|
|
}
|
|
|
|
static get RANGE_FIELDS() {
|
|
return ['invited_at', 'accepted_at'];
|
|
}
|
|
|
|
static get ENUM_FIELDS() {
|
|
return ['access_level', 'is_active'];
|
|
}
|
|
|
|
static get CSV_FIELDS() {
|
|
return [
|
|
'id',
|
|
'access_level',
|
|
'is_active',
|
|
'invited_at',
|
|
'accepted_at',
|
|
'createdAt',
|
|
];
|
|
}
|
|
|
|
static get AUTOCOMPLETE_FIELD() {
|
|
return 'access_level';
|
|
}
|
|
|
|
static get ASSOCIATIONS() {
|
|
return [
|
|
{ field: 'project', setter: 'setProject', isArray: false },
|
|
{ field: 'user', setter: 'setUser', isArray: false },
|
|
];
|
|
}
|
|
|
|
static get FIND_BY_INCLUDES() {
|
|
return [{ association: 'project' }, { association: 'user' }];
|
|
}
|
|
|
|
static get FIND_ALL_INCLUDES() {
|
|
return [
|
|
{ model: db.projects, as: 'project', required: false },
|
|
{ model: db.users, as: 'user', required: false },
|
|
];
|
|
}
|
|
|
|
static get RELATION_FILTERS() {
|
|
return [
|
|
{
|
|
filterKey: 'project',
|
|
model: db.projects,
|
|
as: 'project',
|
|
searchField: 'name',
|
|
},
|
|
{
|
|
filterKey: 'user',
|
|
model: db.users,
|
|
as: 'user',
|
|
searchField: 'firstName',
|
|
},
|
|
];
|
|
}
|
|
|
|
static getFieldMapping(data) {
|
|
return {
|
|
id: data.id || undefined,
|
|
access_level: data.access_level || null,
|
|
is_active: data.is_active || false,
|
|
invited_at: data.invited_at || null,
|
|
accepted_at: data.accepted_at || null,
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = Project_membershipsDBApi;
|