yapi/server/models/interfaceCol.js

60 lines
1.1 KiB
JavaScript
Raw Normal View History

import yapi from '../yapi.js';
import baseModel from './base.js';
class interfaceCol extends baseModel {
getName() {
return 'interface_col';
}
getSchema() {
return {
name: { type: String, required: true },
uid: { type: Number, required: true },
project_id: { type: Number, required: true },
desc: String,
add_time: Number,
2017-08-09 16:16:35 +08:00
up_time: Number
};
}
save(data) {
let m = new this.model(data);
return m.save();
}
get(id) {
return this.model.findOne({
_id: id
}).exec();
}
checkRepeat(name) {
return this.model.count({
name: name
});
}
2017-08-08 19:47:36 +08:00
list(project_id) {
return this.model.find({
project_id: project_id
}).exec();
}
del(id) {
return this.model.deleteOne({
_id: id
});
}
up(id, data) {
data.up_time = yapi.commons.time()
return this.model.update(
{
_id: id
},
data
);
}
}
module.exports = interfaceCol;