denodb
denodb copied to clipboard
Model not passed to "on" event callback
Hi, me again. I was indicated in the documentation, but it doesnt seem to work for me, that the model is passed on the "on" event listener Thats my code
import { DataTypes, Model } from "https://deno.land/x/denodb/mod.ts";
import db from "../databaseManager.ts";
import { format } from "https://deno.land/[email protected]/datetime/mod.ts";
const TOKEN_EXPIRY_LIMIT = 25;
class Flight extends Model {
static table = "flights";
data: any;
// createdAt & updatedAt
static timestamps = true;
static fields = {
key: {
type: DataTypes.STRING,
unique: true,
allowNull: false,
},
value: {
type: DataTypes.STRING,
unique: true,
allowNull: false,
},
};
}
await db.sync({ drop: true });
db.link([Flight]);
Flight.on("updating", (model: any) => {
})
.on("creating", (model: any) => {
console.log("onCreating");
console.log(model);
})
.on("updated", (model: any) => {
console.log("Updated:", model.id);
})
.on("created", (model: any) => {
console.log("Updated:", model.id);
});
export default Flight;
The 'model' in console.logs s undefined. As you can see i tried all of them and at this point im not sure if I missed something or not. Im using MongoDB.
Same for me.