.
This commit is contained in:
parent
e4d403472d
commit
09ab90f923
@ -67,7 +67,7 @@
|
||||
"path": "^0.12.7",
|
||||
"remove": "^0.1.5",
|
||||
"response-time": "^2.3.2",
|
||||
"sequelize": "^6.33.0",
|
||||
"sequelize": "^6.37.3",
|
||||
"sequelize-revision": "^6.0.0",
|
||||
"sequelize-typescript": "^2.1.5",
|
||||
"shallow-equal-object": "^1.1.1",
|
||||
|
||||
@ -80,32 +80,25 @@ export default (sequelize: Sequelize) => {
|
||||
{ name: "updated_at_idx", fields: ["updated_at"] },
|
||||
],
|
||||
|
||||
whereMergeStrategy: "and",
|
||||
scopes: {
|
||||
quickSearch(value) {
|
||||
return {
|
||||
where: {
|
||||
[Op.or]: [
|
||||
{
|
||||
reference: {
|
||||
[Op.like]: `%${value}%`,
|
||||
},
|
||||
[Op.or]: {
|
||||
reference: {
|
||||
[Op.like]: `%${value}%`,
|
||||
},
|
||||
{
|
||||
family: {
|
||||
[Op.like]: `%${value}%`,
|
||||
},
|
||||
family: {
|
||||
[Op.like]: `%${value}%`,
|
||||
},
|
||||
{
|
||||
subfamily: {
|
||||
[Op.like]: `%${value}%`,
|
||||
},
|
||||
subfamily: {
|
||||
[Op.like]: `%${value}%`,
|
||||
},
|
||||
{
|
||||
description: {
|
||||
[Op.like]: `%${value}%`,
|
||||
},
|
||||
description: {
|
||||
[Op.like]: `%${value}%`,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@ -51,7 +51,7 @@ export abstract class SequelizeRepository<T> implements IRepository<T> {
|
||||
modelName: string,
|
||||
field: string,
|
||||
value: any,
|
||||
params: any = {}
|
||||
params: any = {},
|
||||
): Promise<T> {
|
||||
const _model = this.adapter.getModel(modelName);
|
||||
const where: { [key: string]: any } = {};
|
||||
@ -68,7 +68,7 @@ export abstract class SequelizeRepository<T> implements IRepository<T> {
|
||||
protected async _getById(
|
||||
modelName: string,
|
||||
id: UniqueID | string,
|
||||
params: any = {}
|
||||
params: any = {},
|
||||
): Promise<T> {
|
||||
const _model = this.adapter.getModel(modelName);
|
||||
return _model.findByPk(id.toString(), params);
|
||||
@ -77,7 +77,7 @@ export abstract class SequelizeRepository<T> implements IRepository<T> {
|
||||
protected async _findAll(
|
||||
modelName: string,
|
||||
queryCriteria?: IQueryCriteria,
|
||||
params: any = {}
|
||||
params: any = {},
|
||||
): Promise<{ rows: any[]; count: number }> {
|
||||
console.time("_findAll");
|
||||
|
||||
@ -108,7 +108,7 @@ export abstract class SequelizeRepository<T> implements IRepository<T> {
|
||||
modelName: string,
|
||||
field: string,
|
||||
value: any,
|
||||
params: any = {}
|
||||
params: any = {},
|
||||
): Promise<boolean> {
|
||||
const _model = this.adapter.getModel(modelName);
|
||||
const where = {};
|
||||
@ -126,7 +126,7 @@ export abstract class SequelizeRepository<T> implements IRepository<T> {
|
||||
modelName: string,
|
||||
id: UniqueID,
|
||||
data: any,
|
||||
params: any = {}
|
||||
params: any = {},
|
||||
): Promise<void> {
|
||||
const _model = this.adapter.getModel(modelName);
|
||||
|
||||
@ -140,7 +140,7 @@ export abstract class SequelizeRepository<T> implements IRepository<T> {
|
||||
where: { id: id.toString() },
|
||||
transaction: this.transaction,
|
||||
...params,
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
await _model.create(
|
||||
@ -152,7 +152,7 @@ export abstract class SequelizeRepository<T> implements IRepository<T> {
|
||||
include: [{ all: true }],
|
||||
transaction: this.transaction,
|
||||
...params,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -161,7 +161,7 @@ export abstract class SequelizeRepository<T> implements IRepository<T> {
|
||||
modelName: string,
|
||||
id: UniqueID,
|
||||
force: boolean = false,
|
||||
params: any = {}
|
||||
params: any = {},
|
||||
): Promise<void> {
|
||||
const model: ModelDefined<any, any> = this.adapter.getModel(modelName);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user