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

im not able to view my records which is available in collection using pymongo with aadhar datasets
Query with lambda function in pymongo?
backup collection using pymongo
How to update Saved Document Extra data in GridFS
How do I deal with Error stated below?
pymongo query return in direct query not in pymongo
Displaying nested dictionaries in flask-admin
mongoengine slow serialization of embedded documents with reference fields
Pymongo error : 'Cursor' object has no attribute 'find' , how to filter it?
Spark Streaming: foreachRDD insert into mongoDB using python?
how to find right version of bson from pip for pymongo/mongoengine
How to enable `projection` in pymongo query class `find()`?
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

Categories

HOME
ionic2
typelite
paypal-ipn
antd
subdomain
tcsh
stacktrace.js
nsview
ews
tabs
jersey-2.0
cryptography
header
tfs2015
implicit-conversion
impala
supercollider
save
tweepy
swarm
lc3
xamarin-zebble
amazon-emr
tiff
corona
global-variables
rest-assured
c#-7.0
web-deployment
robolectric
codefluent
significance
multiple-tables
cmake-gui
raima
password-generator
spreadsheetgear
history.js
iwebbrowser2
bobo-browse.net
bitbake
social-networking
splunk-query
copy-protection
es6-modules
publishing
payeezy
custom-keyboard
gnu-classpath
directfb
unification
extbase
slideshow
classnotfoundexception
word-cloud
fiware-wirecloud
kitura
webalizer
libreoffice-writer
cordova-ios
sonatype
exc-bad-access
nslayoutconstraint
palindrome
asp.net-web-api-routing
connect-direct
emacs25
boost-compute
wininet
carmen
perforce-integrate
jeasyui
android-async-http
django-validation
myfaces
nette
apple
unidata
debug-symbols
adwords-apiv201402
inequality
category-theory
distributed-r
commenting
property-injection
usb-flash-drive
lsa
ggts
insertonsubmit
postgres-xc
ax
jquery-lazyload
ntlmv2
cyrillic
dojo-1.9
handshake
simplecov
daap
towers-of-hanoi
gitx
android-dialog
opends
fragment-identifier
ognl
suphp
j2mepolish
zend-test
.net-client-profile
inversion
sqlsitemapprovider
activex-exe
webclient.uploaddata

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App