mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-30 13:20:24 +08:00
43 lines
796 B
JavaScript
43 lines
796 B
JavaScript
const yapi = require('../yapi.js');
|
|
const baseModel = require('./base.js');
|
|
|
|
class tokenModel extends baseModel {
|
|
getName() {
|
|
return 'token';
|
|
}
|
|
|
|
getSchema() {
|
|
return {
|
|
project_id: { type: Number, required: true },
|
|
token: String
|
|
};
|
|
}
|
|
|
|
save(data) {
|
|
let m = new this.model(data);
|
|
return m.save();
|
|
}
|
|
|
|
get(project_id) {
|
|
return this.model.findOne({
|
|
project_id: project_id
|
|
});
|
|
}
|
|
|
|
findId(token){
|
|
return this.model.findOne({
|
|
token: token
|
|
}).select('project_id').exec();
|
|
}
|
|
|
|
up(project_id, token){
|
|
return this.model.update({
|
|
project_id: project_id
|
|
}, {
|
|
token: token
|
|
})
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = tokenModel; |