webdevRefinery Forum: Add value to MongoDB dict - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

User is offline Fike 

  • Group: Members
  • Posts: 340
  • Joined: 26-October 10
  • LocationIreland
  • Expertise:PHP,Javascript,Python,SQL

Posted 29 June 2012 - 01:07 PM (#1)

Add value to MongoDB dict


I haven't exactly had too much experience with MongoDB. Say -- for example -- I do something like
db.posts.insert({name: "My first post!", body: "Hello, world! This is my first post.", comments: []})
(forgive this poor example). I want to update that document to add another comment. How would I go about doing this in the mongo shell?
web developer :: HTML, CSS, JavaScript (node), Python, PHP, MySQL, Mongo.
server admin :: experience with debian (and debian based distros), Gentoo, FreeBSD, OpenBSD.
social :: @nixhead (Twitter), Fudge (IRC), Github (FionnK), Personal Blog.
0


User is offline Matthew 

  • Group: Members
  • Posts: 9
  • Joined: 08-March 10
  • Expertise:HTML

Posted 01 August 2012 - 10:14 PM (#2)

See the push operator in the MongoDb documentation. If that isn't enought of a hint to get you moving let me know and I'll give you a little more rope.

http://www.mongodb.o...pdating-%24push
1


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services