Select particular rows

46 views
Skip to first unread message
Message has been deleted

Jafar PA

unread,
May 17, 2012, 8:51:41 AM5/17/12
to mongod...@googlegroups.com



Hi there,

I was wondering if i search for particular row from db.As we are advantaging in SQL db   to get particular row without retrieving whole data ( eg:SELECT * FROM table WHERE id=123 ) so that can perform updates work on specific rows .I am on C# language.
Hope someone can shed some light on this.

Jafar

Sam Millman

unread,
May 17, 2012, 8:55:49 AM5/17/12
to mongod...@googlegroups.com
Without retrieving whole data?

You mean constricting the fields:

find({ //clause }, {_id:0, a: 1}) // Will only return a

Or you mean for "updates" as in:

update({_id: {}}, {$set: { //new fields }})


--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

Jafar PA

unread,
May 17, 2012, 9:31:33 AM5/17/12
to mongod...@googlegroups.com
Thanks for your replay , I am newbie to MongoDB. Could you please share sample code for checking weather a  BSON field exists or not and if it exist how can i update the field.  

Jenna

unread,
May 17, 2012, 2:47:08 PM5/17/12
to mongodb-user
The $exists operator allows you to check for the existence of a field.
 To find and update documents containing "field_example" (in the
shell):

db.collection_name.update({field_example : {$exists: true}},
{field_example: "update"}, false, true);

Shell syntax taken from the mongoDB docs:
db.collection.update( criteria, objNew, upsert, multi )
criteria - query which selects the record to update;
objNew - updated object or $ operators (e.g., $inc) which manipulate
the object
upsert - if this should be an "upsert" operation; that is, if the
record(s) do not exist, insert one. Upsert only inserts a single
document.
multi - indicates if all documents matching criteria should be updated
rather than just one. Can be useful with the $ operators below.

Information about the update() shell syntax can be found here:
http://docs.mongodb.org/manual/reference/javascript/?highlight=update#db.collection.update
If you're using the C# driver, please see:
http://www.mongodb.org/display/DOCS/CSharp+Driver+Tutorial#CSharpDriverTutorial-Updatemethod

On May 17, 9:31 am, Jafar PA <jafar...@gmail.com> wrote:
> Thanks for your replay , I am newbie to MongoDB. Could you please share
> sample code for checking weather a  BSON field exists or not and if it
> exist how can i update the field.
>
>
>
>
>
>
>
> On Thursday, 17 May 2012 18:25:49 UTC+5:30, Sammaye wrote:
>
> > Without retrieving whole data?
>
> > You mean constricting the fields:
>
> > find({ //clause }, {_id:0, a: 1}) // Will only return a
>
> > Or you mean for "updates" as in:
>
> > update({_id: {}}, {$set: { //new fields }})
>
> > On 17 May 2012 13:51, Jafar PA <jafar...@gmail.com> wrote:
>
> >> Hi there,
>
> >>> I was wondering if i search for particular row from db.As we are
> >>> advantaging in SQL db   to get particular row without retrieving whole data
> >>> ( eg:SELECT * FROM table WHERE id=123 ) so that can perform updates work
> >>> on specific rows .I am on C# language.
> >>> Hope someone can shed some light on this.
>
> >>> Jafar
>
> >>  --
> >> You received this message because you are subscribed to the Google
> >> Groups "mongodb-user" group.
> >> To post to this group, send email to mongod...@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> mongodb-user...@googlegroups.com
> >> See also the IRC channel -- freenode.net#mongodb
>
> On Thursday, 17 May 2012 18:25:49 UTC+5:30, Sammaye wrote:
>
> > Without retrieving whole data?
>
> > You mean constricting the fields:
>
> > find({ //clause }, {_id:0, a: 1}) // Will only return a
>
> > Or you mean for "updates" as in:
>
> > update({_id: {}}, {$set: { //new fields }})
>
> > On 17 May 2012 13:51, Jafar PA <jafar...@gmail.com> wrote:
>
> >> Hi there,
>
> >>> I was wondering if i search for particular row from db.As we are
> >>> advantaging in SQL db   to get particular row without retrieving whole data
> >>> ( eg:SELECT * FROM table WHERE id=123 ) so that can perform updates work
> >>> on specific rows .I am on C# language.
> >>> Hope someone can shed some light on this.
>
> >>> Jafar
>
> >>  --
> >> You received this message because you are subscribed to the Google
> >> Groups "mongodb-user" group.
> >> To post to this group, send email to mongod...@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> mongodb-user...@googlegroups.com

Jafar PA

unread,
May 18, 2012, 5:10:13 AM5/18/12
to mongod...@googlegroups.com
Thanks for your replay 

> >> See also the IRC channel -- freenode.net#mongodb
>
> On Thursday, 17 May 2012 18:25:49 UTC+5:30, Sammaye wrote:
>
> > Without retrieving whole data?
>
> > You mean constricting the fields:
>
> > find({ //clause }, {_id:0, a: 1}) // Will only return a
>
> > Or you mean for "updates" as in:
>
> > update({_id: {}}, {$set: { //new fields }})
>
> > On 17 May 2012 13:51, Jafar PA <jafar...@gmail.com> wrote:
>
> >> Hi there,
>
> >>> I was wondering if i search for particular row from db.As we are
> >>> advantaging in SQL db   to get particular row without retrieving whole data
> >>> ( eg:SELECT * FROM table WHERE id=123 ) so that can perform updates work
> >>> on specific rows .I am on C# language.
> >>> Hope someone can shed some light on this.
>
> >>> Jafar
>
> >>  --
> >> You received this message because you are subscribed to the Google
> >> Groups "mongodb-user" group.
> >> To post to this group, send email to mongod...@googlegroups.com
> >> To unsubscribe from this group, send email to
Reply all
Reply to author
Forward
0 new messages