摇摇欲坠
用于 Swagger 的 mongoose CRUD 操作的简单包装器 。 这个插件是Mongoose CRUD操作的调制版本,由 迈克尔·克龙。 。 。 .
这个模块暴露在基本操作之后.
- 创建
- 更新
- 读取
- 删除
- 索引(列表)
- 计数
- 更新日期
- 散装负荷
- 批量显示
- 标记已删除
- 吕克
安装
npm install @appveen/swagger-mongoose-crud --save
使用量
var Mongoose = require('@datanimbus/mongoose');
var SMCrud = require('swagger-mongoose-crud');
//In your controller, simply expose the following
var schema = new Mongoose.Schema({
//Your mongoose Schema definition here.
});
var modelName = "Your model Name";
var options = {
collectionName: "name of your collection",
logger: "your logger object",
defaultFilter: "default filter object for all read operations",
permanentDeleteData: "To be set true, when soft delete is disabled"
}
var crud = new SMCrud(schema,modelName, options);
var exports = {};
//Takes all parameters for creating an entry
exports.create = crud.create;
//Takes parameter 'id' for searching in the DB, will update rest of the parameters.
exports.update = crud.update;
//Will list out the entire collection, No parameters
exports.index = crud.index;
//Will mark the entity as deleted by setting deleted flag to true, takes 'id'
exports.markAsDeleted = crud.markAsDeleted;
//Will delete the entity, takes 'id'
exports.destroy = crud.destroy;
//Will show a single entity, takes 'id'
exports.show = crud.show;
//Will count the number of entries in the DB, Supports filter options.
exports.count = crud.count;
//Will update multiple document, takes comma separated 'id'
exports.bulkUpdate = crud.bulkUpdate;
//Will create multiple documents, takes file with comma separated data
exports.bulkUpload = crud.bulkUpload;
//Will show multiple entity, takes comma separated 'id'
exports.bulkShow = crud.bulkShow;
// Will ensure consistency when there are multiple parallel updates expected on the same document. This module is partially incomplete.
exports.rucc = crud.rucc;
//crud.model will hold the Mongoose Model.
//crud.schema will hold the schema passed on at constructor
crud.select = [
//list of the fields for the listing in Index call
];
crud.omit = [
//list of the fields to disallow for Index search
];
module.exports = exports;
此库添加到您的计划中的字段
- 创建到 : 类型 日期. 创建文件的时间
- 上次更新 : 类型 日期。文档的最后更新时间
- 删除 : 类型 布尔。这默认是错误的。 这个
索引字段
- 上次更新
- 创建到 。 。 。 .