feat(db): init mongo and passing komga conf
This commit is contained in:
35
src/lib/models/config.model.ts
Normal file
35
src/lib/models/config.model.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const configSchema = new mongoose.Schema(
|
||||
{
|
||||
userId: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
username: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
password: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
}
|
||||
);
|
||||
|
||||
// Middleware pour mettre à jour le champ updatedAt avant la sauvegarde
|
||||
configSchema.pre("save", function (next) {
|
||||
this.updatedAt = new Date();
|
||||
next();
|
||||
});
|
||||
|
||||
export const KomgaConfig =
|
||||
mongoose.models.KomgaConfig || mongoose.model("KomgaConfig", configSchema);
|
||||
Reference in New Issue
Block a user