sequelize#Utils TypeScript Examples
The following examples show how to use
sequelize#Utils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: sequelize.ts From ucast with Apache License 2.0 | 6 votes |
export function createInterpreter(interpreters: Record<string, SqlOperator<any>>) {
const interpretSQL = createSqlInterpreter(interpreters);
return (condition: Condition, Model: ModelType) => {
const dialect = Model.sequelize!.getDialect() as keyof typeof dialects;
const options = dialects[dialect];
if (!options) {
throw new Error(`Unsupported database dialect: ${dialect}`);
}
const [sql, params, joins] = interpretSQL(condition, options, Model);
return {
include: joins.map(association => ({ association, required: true })),
where: literal(Utils.format([sql, ...(params as string[])], dialect)),
};
};
}