Last active
August 29, 2015 14:03
-
-
Save konsumer/9aa1859284089904b6f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var models = require('../models'), | |
mongoose = require('mongoose'); | |
module.exports = function(app) { | |
var angularBridge = new (require('angular-bridge'))(app, { | |
urlPrefix : '/api/' | |
}); | |
// add API interface for all models | |
for (modelName in models){ | |
if (modelName != 'User'){ | |
var Model = models[modelName]; | |
// require ownership on all records | |
angularBridge.addResource(modelName.toLowerCase(), Model, { | |
query: '{_user: String(req.user._id)}', | |
force: { | |
_user: 'req.user._id' | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment