pymongo


pymongo collection add item using update


desperately I look for a solution of a very simple problem. I use NINJA and Robomongo as
environment.
I want to add a collection to an existing one, all in the same FOR loop:
existing:
{
"_id" : ObjectId("54608d9f35121b0e18aa01b2"),
"level1" : {
"item1" : 200.55,
"item2" : "001",
"item3" : 708874,
}
}
want to get:
{
"_id" : ObjectId("54608d9f35121b0e18aa01b2"),
"level1" : {
"item1" : 200.55,
"item2" : "001",
"item3" : 708874,
"level2" : {
"item4" : 200.55,
"item5" : "001",
"item6" : 708874,
}
}
}
I tried UPDATE with $set (unset=True), $addToSet etc. Problem seems that it's not an array.
Thanx for help
found the solution in this forum:
Pymongo how to properly use $push to update an existing document
The first answer was
This query works.
db.foo.update({"node": "denver"}, {"$set": {"enc.classes.boulder": ""}}
And this works in my case!
Thanx all

Related Links

Can't replace mongo document
How do I call a function with pymongo using webpy?
python motor offers fetch_next exception on aggregation
python motor mongo cursor length or peek next
PyMongo check if update succeeded
insert and query an OrderedDict in MongoHQ
Return .str of ObjectID using pymongo
Selecting the lowest/highest with find_one in Pymongo
Safe use of Pymongo's find_one
Pymongo $in + $regex
How can I get pymongo to always return str and not unicode?
SON Manipulator in mongo queries
How to append a document to a 2nd level embedded model list document in Django and mongoengine
pymongo multiple update $in
How to get negetive of a complex where clause in mongo db
pymongo justOne & multi

Categories

HOME
lambda
opencart
weblogic12c
concurrency
foaf
plaid
ios-simulator
apk
azure-data-lake
share
solution
fireloop
documentum
spring-amqp
synthesis
heap-dump
http-authentication
nullreferenceexception
spring-shell
pymongo
eclipse-emf
exchange-server-2010
dragula
marquee
basic-authentication
opnet
epplus
cloudera-manager
busboy
pdfminer
pdfnet
xvfb
mv
linq.js
assemblies
spring-restcontroller
swfupload
slideshow
klee
opal-framework
1wire
morphline
moinmoin
xcode8.2
liteide
swift2.3
windows-media-player
sonarqube5.2
xcglogger
hibernate-ogm
nslayoutconstraint
deedle
sidewaffle
adobe-reader
libharu
nclam
nsrunloop
dojo-build
bbc-micro
maximize
urbit
teamviewer
django-validation
m4
sequence-sql
r.java-file
python-c-extension
dc
global-scope
smacss
tabris
ecos
loginview
rpg
rails-api
xulrunner
nodeload
oxygene
mod-perl
profiles
sql-view
postgres-xc
asp.net-mvc-3-areas
icenium
smartfox
simplecov
semantic-merge
opends
wiktionary
kext
libxslt
odac
projectpier
processors
fuzzy-comparison
version-control-migration

Resources

Encrypt Message