yapi/server/models/interface.js

31 lines
563 B
JavaScript
Raw Normal View History

2017-07-03 16:16:05 +08:00
import mongoose from 'mongoose'
const Schema = mongoose.Schema;
const interfaceSchema = new Schema({
title: String,
content: String,
uid: String
})
var interfaceModel = mongoose.model('interface', interfaceSchema);
function save(data){
let m = new interfaceModel(data);
return m.save();
}
function findById(id){
return interfaceModel.findOne({
_id: id
}, 'title content')
}
function find(){
return interfaceModel.find({title: 2222}).exec()
}
module.exports = {
save: save,
findById: findById,
find: find
}