get my collectivity
*/
router.get('/', function(req, res){
- Models.Collectivity.where('id', req.token.collectivity_id).fetch({withRelated: ['collectivitySon.collectivitySon']})
+ Models.Collectivity.where('id', req.token.collectivity_id).fetch({withRelated: ['collectivitySon.collectivitySon','collectivityMother.collectivityMother']})
.then(function(coll){
console.log(coll.toJSON());
res.json({success: true, message:coll.toJSON()})
router.post('/linkToOne', function(req,res) {
console.log(req.body);
+ console.log(req.token.collectivity_id);
new Models.Collectivity_Collectivity({
'collectivity_motherid': req.token.collectivity_id,
- 'collectivity_sonid': req.body.sonId
+ 'collectivity_sonid': req.body.collectivity_sonid
})
.save()
.then(function (model) {
})
.catch(function(err){
console.log(err);
- res.json({success : false});
+ res.json({success : false, message: err});
});
});
console.log(req.body);
new Models.Collectivity_Collectivity({
'collectivity_motherid': req.token.collectivity_id,
- 'collectivity_sonid': req.body.sonId
+ 'collectivity_sonid': req.body.collectivity_sonid
}).where({'collectivity_motherid': req.token.collectivity_id,
- 'collectivity_sonid': req.body.sonId})
+ 'collectivity_sonid': req.body.collectivity_sonid})
.destroy()
.then(function (model) {
res.json({success : true});
-
-
-
-
router.get('/notules', function(req, res){
Models.Collectivity_Notule.where('collectivity_id',req.token.collectivity_id).fetchAll({withRelated: ['notule']})