Archived
2
This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
definma-api/src/models/model.ts
2020-08-26 19:37:36 +02:00

20 lines
526 B
TypeScript

import mongoose from 'mongoose';
import db from '../db';
const ModelSchema = new mongoose.Schema({
group: {type: String, index: {unique: true}},
models: [new mongoose.Schema({
name: String,
url: String,
label: String
} ,{ _id : true })]
});
// changelog query helper
ModelSchema.query.log = function <Q extends mongoose.DocumentQuery<any, any>> (req) {
db.log(req, this);
return this;
}
ModelSchema.index({group: 1});
export default mongoose.model<any, mongoose.Model<any, any>>('model', ModelSchema);