Mongoose模型到breezejs元数据



我在后端使用mongoose来定义我的模型;所以在前端,我想让breezeJS知道元数据。

是否有任何方法可以在使用mongoose定义的模式之外创建元数据?

我试着写一个小的npm包来处理这个问题

https://www.npmjs.org/package/breeze-mongoose

//Create a function that returns a mongoose model
var mongoose = require('mongoose'),
   dbConnection = mongoose.createConnection(mongodb_connection_string),
   modelContainer = function getModel(model){ // the name of the model
     return dbConnection .model(model);
   },
   dbSchemas = dbConnection.models;
//Add the getMetadata endpoint to your API
    var breezeMongoose = require('breeze-mongoose')(modelContainer);
    app.get('breeze/metadata', function(req, res){
         res.json(breezeMongoose.getMetadata(dbSchemas ));
    })
//Add the saveChanges endpoint
app.post(function(req, res){
        breezeMongoose.saveChanges(req.body)
            .then(function(saveResults){
             res.json(saveResults);
        })
        .catch(function(message){
            res.send(500, message);
        });
    });

还没有,但这是个好主意。也许你可以把这个作为一个请求添加到微风用户的声音。你可以在这里投票:https://breezejs.uservoice.com/forums/173093-1-breezejs-feature-suggestions

最新更新