Skip to content

Commit

Permalink
use debug
Browse files Browse the repository at this point in the history
  • Loading branch information
sobird committed Jan 12, 2024
1 parent a1752a8 commit bf834dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 7 additions & 5 deletions lib/sequelize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* sobird<[email protected]> at 2021/11/16 20:33:20 created.
*/

import debug from 'debug';
import {
Sequelize, Model, CreationOptional, ModelStatic, InferAttributes,
} from 'sequelize';
Expand Down Expand Up @@ -111,10 +112,12 @@ export const sequelize = new Sequelize({
// isolation level of each transaction
// defaults to dialect default
// isolationLevel: Transaction.ISOLATION_LEVELS.REPEATABLE_READ
logging: (queryString, queryObject: any) => {
console.log(queryObject.type, '==>', queryString); // outputs a string
if (queryObject.type === 'INSERT' || queryObject.type === 'BULKUPDATE') {
console.log(queryObject.bind);
logging: (sql, queryObject: any) => {
const { type, bind } = queryObject;
const log = debug(`app:sql:${type}`);
log(sql);
if (['INSERT', 'UPDATE', 'BULKUPDATE'].includes(type)) {
log(bind);
}
},
});
Expand Down Expand Up @@ -145,7 +148,6 @@ export class BaseModel<T extends {} = any, P extends {} = T> extends Model<T, P>

public static async findManyWithAccessible<T extends AbilityTuple>(ability: MongoAbility<T>) {
// todo

console.log('ability', ability);
}

Expand Down
1 change: 1 addition & 0 deletions models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ User.init(
},
status: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: true,
},
createdBy: {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"dev": "next dev",
"dev": "DEBUG=app:* next dev",
"start": "next start",
"build": "next build",
"lint": "next lint",
Expand All @@ -22,6 +22,7 @@
"axios": "^1.6.2",
"classnames": "^2.3.2",
"dayjs": "^1.11.10",
"debug": "^4.3.4",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",
"next": "^14.0.3",
Expand Down

0 comments on commit bf834dd

Please sign in to comment.