NodeJS and MongoDB.js no update

59 views
Skip to first unread message

Yvon Thoraval

unread,
Dec 16, 2013, 1:43:26 AM12/16/13
to nod...@googlegroups.com
I whish to update a collection 'pages' in a database.

I get no error, however, updates aren't applied.

i prepare de fields to insert/update :

var page2update={
    source_id: source._id.toString()
  , mtime:     new Date()
};


pages_collection.update({_id: page._id}, {$set: page2update}, {safe: 1}, function(err, result) {
  if(err){
    console.log((new Date()) + " An error occurs: "+err);
  }else{
    console.log((new Date()) + " result = "+result);
  }
});

on the console i got :
Mon Dec 16 2013 07:11:59 GMT+0100 (CET) result = 1

meaning the result is ok ?

i have tested also for the options part of this command {w: 1} and also no options at all (default?).

the results are the same : no update.
nor the filed mtime (modify time) is updated,
nor the field 'source_id' is created, why ?

i have used the same kind of update in another db (using option {w: 1}) successfully.

any idae ?
Message has been deleted

Yvon Thoraval

unread,
Dec 16, 2013, 2:58:13 AM12/16/13
to nod...@googlegroups.com
Hi Carolin,

I don't agree because "source_id" is a NEW field of page.
In fact, up to this time i have, for page a field named "source" i wish to replace by source_id.
then i created a new collection 'sources' from all the distinct 'source' field in pages.
each document of sources collection has an _id i want to put (as string) into the 'source_id' field of a page document of pages.
the page itself being compared by its own _id as an ObjectID.


2013/12/16 Carolin Etzold <carolin...@googlemail.com>
Hi,

maybe you should try not to parse source._id to string. 
In my opinion MongoDB can not compare "source_id" with "source.id.toString()".
The source_id itself is from type ObjectId and not string.

--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
 
---
You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/nvv-zXCCsv8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Yvon@48.871651804,2.384858688

Yvon Thoraval

unread,
Dec 16, 2013, 5:26:11 AM12/16/13
to nod...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages