K
K
Konstantin Malyarov2020-02-13 00:23:06
Python
Konstantin Malyarov, 2020-02-13 00:23:06

Why does it return immutable records?

import pymongo

conn = pymongo.MongoClient("localhost", 27017)
db = conn["crypto_signals"]
signals_db = db["signals"]
signals_db.update({}, {"$set": {"priority": 0}}, )
signals = signals_db.find({"priority":{"$exists":False}})

for signal in signals:
    print(signal)


The print command returns the part of the records that has not been changed, the priority field is missing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Smykov, 2020-02-13
@Konstantin18ko

update should be replaced with update_many
And everything will work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question