2
0
mirror of https://github.com/YMFE/yapi.git synced 2025-01-12 12:54:48 +08:00
yapi/server/models/project.js

44 lines
898 B
JavaScript

import yapi from '../yapi.js'
const projectSchema = {
uid: String,
name: String,
basepath: String,
desc: String,
group_id: String,
members: Array,
prd_host: String,
env: Object,
add_time: Number,
up_time: Number
}
var projectModel = yapi.db('project', projectSchema);
module.exports = {
save: (data) => {
let m = new projectModel(data);
return m.save();
},
checkRepeat: (name, basepath) => {
return projectModel.count({
project_name: name,
basepath: basepath
})
},
list: () => {
return projectModel.find().exec()
},
del: (id) => {
return projectModel.deleteOne({
_id: id
})
},
up: (id, data) => {
data.up_time = yapi.commons.time();
return projectModel.update({
_id: id,
}, data)
}
}