UNPKG

@hicoder/express-core

Version:

Restful API exposure middleware for Express and Mongoose based framework. Provide Rest API automatically based on Mongoose schema. It can also work with angular-core to develop end to end MEAN stack web applications.

72 lines (65 loc) 1.45 kB
const mongoose = require('mongoose'); const Schema = mongoose.Schema; const historySchema = new Schema( { oid: { type: String, required: true, }, module: { type: String, }, schema: { type: String, required: true, }, action: { type: String, enum: ['delete', 'insert', 'update'], }, user: { type: String, }, document: { type: String, }, }, { timestamps: true, } ); const brief = 'oid module schema action user createdAt'; const detail = 'oid module schema action user createdAt document'; const create = 'oid module schema action user document'; const edit = 'oid module schema action user document'; const search = 'oid module schema'; const index = 'oid'; const historySchemaDef = { schema: historySchema, views: [brief, detail, create, edit, search, index], name: 'Document History', api: 'LR', mraUI: { listWidgets: { general: { views: ['table'], }, select: { views: ['table'], }, sub: { views: ['table'], }, }, listWidgetTypes: { general: 'general', select: 'select', sub: 'sub', }, defaultListSort: {'createdAt': 'desc'}, }, mraBE: { collection: `${process.env.APP_NAME}_mddscore_history`, // Every module including the history featuer will use the same collection. }, }; module.exports = historySchemaDef;