@autofleet/sadot 0.5.5-beta.0 → 0.5.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -6
- package/package.json +1 -1
- package/src/index.ts +9 -7
package/dist/index.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export * from './utils/constants';
|
|
|
11
11
|
declare const useCustomFields: (app: Application | null, getModel: ModelFetcher, options: CustomFieldOptions) => Promise<Sequelize>;
|
|
12
12
|
export default useCustomFields;
|
|
13
13
|
export declare const disableCustomFields: (models: any, getModel: any) => void;
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const buildCustomFieldsSearchWhereClause: (searchTerm: string) => WhereOptions;
|
package/dist/index.js
CHANGED
|
@@ -17,8 +17,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.buildCustomFieldsSearchWhereClause = exports.disableCustomFields = void 0;
|
|
21
21
|
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
22
|
+
const sequelize_1 = require("sequelize");
|
|
22
23
|
const models_1 = require("./models");
|
|
23
24
|
const api_1 = __importDefault(require("./api"));
|
|
24
25
|
const db_1 = __importDefault(require("./utils/db"));
|
|
@@ -51,8 +52,11 @@ const disableCustomFields = (models, getModel) => {
|
|
|
51
52
|
(0, init_1.removeHooks)(models, getModel);
|
|
52
53
|
};
|
|
53
54
|
exports.disableCustomFields = disableCustomFields;
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const buildCustomFieldsSearchWhereClause = (searchTerm) => ({
|
|
56
|
+
where: {
|
|
57
|
+
[sequelize_1.Op.or]: [
|
|
58
|
+
sequelize_typescript_1.Sequelize.where(sequelize_typescript_1.Sequelize.cast(sequelize_typescript_1.Sequelize.col('customFieldValue.value'), 'text'), { [sequelize_1.Op.iLike]: `%${searchTerm}%` }),
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
exports.buildCustomFieldsSearchWhereClause = buildCustomFieldsSearchWhereClause;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Application } from 'express';
|
|
2
2
|
import { Sequelize } from 'sequelize-typescript';
|
|
3
|
-
import { WhereOptions } from 'sequelize';
|
|
3
|
+
import { WhereOptions, Op } from 'sequelize';
|
|
4
4
|
import {
|
|
5
5
|
initTables, initTestModels,
|
|
6
6
|
} from './models';
|
|
@@ -45,10 +45,12 @@ export const disableCustomFields = (models, getModel): void => {
|
|
|
45
45
|
removeHooks(models, getModel);
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
export const
|
|
49
|
-
modelName: string,
|
|
48
|
+
export const buildCustomFieldsSearchWhereClause = (
|
|
50
49
|
searchTerm: string,
|
|
51
|
-
) : WhereOptions =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
) : WhereOptions => ({
|
|
51
|
+
where: {
|
|
52
|
+
[Op.or]: [
|
|
53
|
+
Sequelize.where(Sequelize.cast(Sequelize.col('customFieldValue.value'), 'text'), { [Op.iLike]: `%${searchTerm}%` }),
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
});
|