FAQ

[mongodb-user] how can i insert values into BSONObj and BSONArray?

Ma fuli
Feb 21, 2012 at 5:56 am
(1)in the beginning, i create a new BSONObj obj1=BSON("name"<<"fuli");
how can i add a new key-value into the object obj1, such as how can i
add {serx,male} into the obj1;
(2)i create a new BSONArray
arr=BSON_ARRAY(1<<2<<3<<BSON("name"<<"fuli"));
how to add a new element into the arr array, Thanks a lot.

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongodb-user@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
reply

Search Discussions

6 responses

  • Nat at Feb 21, 2012 at 6:02 am
    Check out BSONArrayBuilder and BSONObjBuilder.
    -----Original Message-----
    From: ma fuli <fulim007@gmail.com>
    Sender: mongodb-user@googlegroups.com
    Date: Mon, 20 Feb 2012 21:56:21
    To: mongodb-user<mongodb-user@googlegroups.com>
    Reply-To: mongodb-user@googlegroups.com
    Subject: [mongodb-user] how can i insert values into BSONObj and BSONArray?

    (1)in the beginning, i create a new BSONObj obj1=BSON("name"<<"fuli");
    how can i add a new key-value into the object obj1, such as how can i
    add {serx,male} into the obj1;
    (2)i create a new BSONArray
    arr=BSON_ARRAY(1<<2<<3<<BSON("name"<<"fuli"));
    how to add a new element into the arr array, Thanks a lot.

    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Ma fuli at Feb 21, 2012 at 6:02 am
    can you give me some examples, Thanks
    On 2月21日, 下午2时01分, "Nat" wrote:
    Check out BSONArrayBuilder and BSONObjBuilder.







    -----Original Message-----
    From: ma fuli <fulim...@gmail.com>
    Sender: mongodb-user@googlegroups.com
    Date: Mon, 20 Feb 2012 21:56:21
    To: mongodb-user<mongodb-user@googlegroups.com>
    Reply-To: mongodb-user@googlegroups.com
    Subject: [mongodb-user] how can i insert values into BSONObj and BSONArray?

    (1)in the beginning, i create a new BSONObj obj1=BSON("name"<<"fuli");
    how can i add a new key-value into the object obj1, such as how can i
    add {serx,male} into the obj1;
    (2)i create a new BSONArray
    arr=BSON_ARRAY(1<<2<<3<<BSON("name"<<"fuli"));
    how to add a new element into the arr array, Thanks a lot.

    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group athttp://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Ma fuli at Feb 21, 2012 at 6:04 am
    ps: in C++ language
    On 2月21日, 下午1时56分, ma fuli wrote:
    (1)in the beginning, i create a new BSONObj obj1=BSON("name"<<"fuli");
    how can i add a new key-value into the object obj1, such as how can i
    add {serx,male} into the obj1;
    (2)i create a new BSONArray
    arr=BSON_ARRAY(1<<2<<3<<BSON("name"<<"fuli"));
    how to add a new element into the arr array, Thanks a lot.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Barrie at Feb 21, 2012 at 7:57 pm
    Hey Ma,

    You should check out the C++ tutorial in the mongodb documentation
    here: http://www.mongodb.org/pages/viewpage.action?pageId=133415

    Hope this helps.

    Barrie
    On Feb 21, 1:03 am, ma fuli wrote:
    ps: in C++ language

    On 2月21日, 下午1时56分, ma fuli wrote:






    (1)in the beginning, i create a new BSONObj obj1=BSON("name"<<"fuli");
    how can i add a new key-value into the object obj1, such as how can i
    add {serx,male} into the obj1;
    (2)i create a new BSONArray
    arr=BSON_ARRAY(1<<2<<3<<BSON("name"<<"fuli"));
    how to add a new element into the arr array, Thanks a lot.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Ma fuli at Feb 22, 2012 at 2:02 am
    Thank you very much ,i have already study the C++ tutorial, and the
    the mongodb source code, but i find there are very little introduction
    about BSONArray insert operation
    On 2月22日, 上午3时56分, Barrie wrote:
    Hey Ma,

    You should check out the C++ tutorial in the mongodb documentation
    here:http://www.mongodb.org/pages/viewpage.action?pageId=133415

    Hope this helps.

    Barrie

    On Feb 21, 1:03 am, mafuliwrote:






    ps: in C++ language
    On 2月21日, 下午1时56分, mafuliwrote:
    (1)in the beginning, i create a new BSONObj obj1=BSON("name"<<"fuli");
    how can i add a new key-value into the object obj1, such as how can i
    add {serx,male} into the obj1;
    (2)i create a new BSONArray
    arr=BSON_ARRAY(1<<2<<3<<BSON("name"<<"fuli"));
    how to add a new element into the arr array, Thanks a lot.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Nat at Feb 22, 2012 at 2:06 am
    Take a look at this:
    http://www.mongodb.org/pages/viewpage.action?pageId=19562815

    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/cYxop2hM84kJ.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Related Discussions

Discussion Navigation
viewthread | post

3 users in discussion

Ma fuli: 4 posts Nat: 2 posts Barrie: 1 post