ForEach

28 views
Skip to first unread message

Chris Lowe

unread,
Aug 1, 2012, 10:54:41 AM8/1/12
to mongodb...@googlegroups.com
Can anyone tell me if it is possible to run JavaScript via forEach using the C# driver?  For example, I'd like to run something like the following:

db.ColA.find({ _id : { $in: [ 575 ] } }).forEach( function(x) {
db. ColB.insert(x);
}
});

Regards,

Chris

Chris Lowe

unread,
Aug 1, 2012, 11:44:44 AM8/1/12
to mongodb...@googlegroups.com
I've discovered that I can use Eval for now, but if there's a better way then I'd be interested to know.

var js = @"db.ColA.find({ _id : { $in: [ 575 ] } }).forEach( function(x) {
db. ColB.insert(x);
}
});";

Database.Eval(new BsonJavaScript(js));


Cheers,

Chris.
Reply all
Reply to author
Forward
0 new messages