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

Variables don't hold value for very long pymongo ipython
pymongo upgrade to 3.0.3 causes this statement to fail
UUID to NUUID in Python
how to test for empty mongodb query in pymong
read video file from mongodb with pymongo
Get OperationFailure error with PyMongo 2.7.1
Inserting string as regular string in mongodb
Mongos + Pymongo 2.5 ==>No suitable hosts found
pymongo collection add item using update
How to convert objectid to string
Conditional atomic mongo remove with different results
python script to connect to mongodb master
flask-admin and pymongo search
Running code when mongoengine loads a document
Can't replace mongo document
How do I call a function with pymongo using webpy?

Categories

HOME
office365
tomcat
verification
freeradius
functional-programming
postgresql-9.4
operating-system
iverilog
magento-2.0
jersey-2.0
elisp
iptables
angular-meteor
save
pyresttest
roku
fireloop
clish
pm2
mailgun
mixpanel
string-formatting
mime-types
amazon-sns
vuforia
raima
list-comprehension
npoi
sendmessage
argv
quick-nimble
amazon-kms
wdk
installanywhere
ng-repeat
xll
extbase
android-n
right-click
viewcontroller
spooler
adblock
intellij-lombok-plugin
roracle
openstack-glance
palindrome
gmaps.js
kendo-treeview
oid
multi-touch
mathjs
livecycle
ftp-client
maven-release-plugin
uibinder
mercurial-extension
opencyc
directx-9
pythonxy
wso2ml
modern.ie
embeddedwebserver
textscan
ipod
tree-structure
mgwt
subview
incron
debug-symbols
nanomsg
sql-processor
wicket-1.5
device-admin
xcode6.3.1
lumia-imaging-sdk
accessory
two.js
incognito-mode
hyperloglog
reference-counting
thruway
fileshare
typesafe-stack
iosched
mft
apportable
arel
significant-digits
wndproc
image-formats
liveconnect
uploading
multidrop-bus
haiku
space-partitioning
anonymous-types
mongrel2
suphp
ios-4.2
chunking
3270
downcasting
index.dat
activex-exe
bindable-linq
jvm-bytecode

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App