Saturday, 15 June 2013

node.js - _id of mongo document subtracts one on jade -



node.js - _id of mongo document subtracts one on jade -

i finding rare problem between node controller, info base of operations (mongodb), , engine template jade. show piece of code , after explain you.

code

the controller:

router.get('/get_my_buildings', function(req, res) { if(req.session && req.session.user && (req.session.user.rol=="admin" || req.session.user.rol=="superadmin")) buildingdb.getbuilding({admin_id:req.session.user._id}, function(results) { if(results.error==1 || results.result.length==0) res.render('resource_not_found'); else res.render('buildings/admin_buildings', {title:"wellcome", user:req.session.user, buildings: results.result}); }); else res.render('users/loggin', {title:"logging"}); });

jade:

div(style="display: table;") building in buildings div(style="display: table-row;" class="search_hit") div(style="display: table-cell;" class="not_search") span.glyphicon.glyphicon-map-marker div(style="display: table-cell;" class="inline") #{building.address[0].address} div(style="display: table-cell;" class="inline") #{building.address[0].city} div(style="display: table-cell;" class="inline") #{building.address[0].province} div(style="display: table-cell;" class="inline not_search input-group input-group-sm") a(type="button" href="/setup_building/#{building.address[0]._id}" class="btn btn-info inline") span.glyphicon.glyphicon-tags.right-margin |setup else li i´m sorry, there no building show.

the problem i´m finding here: href="/setup_building/#{building.address[0]._id}" allways subtracts 1 @ id should write. example, id should writen is: 545d384b9c33e76c07ba510d, writes: 545d384b9c33e76c07ba510e. other dates right. doing wrong??

thank much. ps: i´m using express

i know problem now. result when create "all buildings" request:

{ "_id": "545d384b9c33e76c07ba510d", ... "address": [{ ... "_id": "545d384b9c33e76c07ba510e" }] }, { "_id": "545d5afc8e0295001bdf44e0", ... "address": [{ ... "_id": "545d5afc8e0295001bdf44e1" }] }

there 2 similar _id onto building. own id of building, , _id of address object, similar:

building: 545d384b9c33e76c07ba510d address: 545d384b9c33e76c07ba510e

node.js mongodb express mongoose jade

No comments:

Post a Comment