| 12345678910111213141516171819202122232425262728293031323334353637 |
- /**
- * Created by CSL on 2018-12-17.
- */
- let mongoose = require('mongoose');
- let blModel = mongoose.model('blockLibsModel');
- module.exports = {
- getLibNames: getLibNames,
- getLib: getLib,
- save: save,
- saveBlock: saveBlock
- };
- async function getLibNames(userID, compilationID) {
- let libNames = await blModel.find({userID: userID, compilationID: compilationID});
- return libNames;
- };
- async function getLib(libID) {
- let lib = await blModel.findOne({libID: libID});
- return lib;
- };
- async function save(data, callback) {
- //
- };
- async function saveBlock(data) {
- await blModel.update({libID: data.libID}, {"$addToSet": {"datas": data}});
- };
- // test Model and write DB functions.
- // function cbExec(err) {if (err) {console.log(err)} else {console.log('saved.')}};
- // async function testData(obj) {await blModel.create(obj, cbExec)};
- // let obj = {"userID":"2164","libID":25,"libName":"模板库25","datas":[],"share":{shareName: 'CSL共享库', shareTo: [2,3,4]}};
- // testData(obj);
|