mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-23 12:57:26 +08:00
fixes missing _id error
This commit is contained in:
@@ -69,9 +69,11 @@ module.exports = {
|
||||
|
||||
remove: ready(function(model) {
|
||||
collection(db, model, function(err, collection) {
|
||||
var id = ObjectID(model.get('_id'));
|
||||
var id = model.get('_id')
|
||||
, _id = id && ObjectID(id)
|
||||
;
|
||||
|
||||
collection.remove({_id: id});
|
||||
collection.remove({_id: _id});
|
||||
model.refresh({removed: true});
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -246,6 +246,7 @@ Model = module.exports = emitter.spawn({
|
||||
}
|
||||
|
||||
function error() {
|
||||
arguments[0] = arguments[0].replace('{key}', key);
|
||||
_self.error.apply(_self, arguments);
|
||||
}
|
||||
|
||||
@@ -414,11 +415,14 @@ Model = module.exports = emitter.spawn({
|
||||
;
|
||||
|
||||
function handler(req, res) {
|
||||
var query = req.params
|
||||
var query = req.query
|
||||
, id = req.param('id')
|
||||
, action = methodMap[req.method] || 'fetch'
|
||||
;
|
||||
|
||||
model
|
||||
if(id && !query._id) query._id = id;
|
||||
|
||||
var m = model
|
||||
.spawn()
|
||||
.for(req)
|
||||
.find(query)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var app = require('../../app')
|
||||
, App = require('./app')
|
||||
, Invite = require('./invite')
|
||||
;
|
||||
|
||||
if(process.argv.length < 3) {
|
||||
@@ -9,15 +10,29 @@ if(process.argv.length < 3) {
|
||||
app.post('/app', function(req, res) {
|
||||
var session = req.session
|
||||
, me = session && session.user && session.user.email
|
||||
, secret = req.param('secret')
|
||||
, app = App.spawn().for(req).notify(res)
|
||||
;
|
||||
|
||||
App
|
||||
Invite
|
||||
.spawn()
|
||||
.for(req)
|
||||
.set({name: req.param('name'), creator: me})
|
||||
.notify(res)
|
||||
.save()
|
||||
.unlock()
|
||||
.find({secret: secret})
|
||||
.set({left: 0})
|
||||
.notify(function(json) {
|
||||
if(json.errors || !json.left) {
|
||||
app.error('Invalid secret');
|
||||
}
|
||||
|
||||
app
|
||||
.set({name: req.param('name'), creator: me})
|
||||
.save()
|
||||
;
|
||||
})
|
||||
.fetch()
|
||||
;
|
||||
|
||||
|
||||
});
|
||||
|
||||
app.get('/app/:id', function(req, res) {
|
||||
|
||||
@@ -34,8 +34,8 @@ app.get('/settings/:name', function(req, res) {
|
||||
// create or update general app settings
|
||||
Setting
|
||||
.spawn()
|
||||
.find({plugin: 'app'})
|
||||
.find({plugin: 'app', name: 'app'})
|
||||
.set(config)
|
||||
.set({plugin: 'app'})
|
||||
.set({plugin: 'app', name: 'app'})
|
||||
.save()
|
||||
;
|
||||
|
||||
@@ -57,7 +57,15 @@ exports.compile = function(source) {
|
||||
var sourceType = typeof source
|
||||
, type = sourceType === 'string' ? source : source && source.type
|
||||
, validator = sourceType === 'function' ? source : validators[type]
|
||||
, required = sourceType === 'object' && source.required
|
||||
;
|
||||
|
||||
if(required) {
|
||||
return function(val, error) {
|
||||
if(!val) error('{key} is required', 'Validation');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return validator || function() {};
|
||||
}
|
||||
@@ -17,7 +17,8 @@ var user = {
|
||||
var auth;
|
||||
|
||||
var app = {
|
||||
name: 'My Testing App'
|
||||
name: 'My Testing App',
|
||||
secret: 'tag soup'
|
||||
};
|
||||
|
||||
var tests = {
|
||||
@@ -83,7 +84,6 @@ var tests = {
|
||||
},
|
||||
after: function(result) {
|
||||
app = result;
|
||||
console.log(app);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user