N
N
N3K2011-10-31 12:46:45
MongoDB
N3K, 2011-10-31 12:46:45

How to update one field for all records in one collection in mongodb?

There is a field - viewsMonth, which needs to be reset to zero on the 1st of each month. How can this be done with a single request without getting records from the database and updating by ID?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sajgak, 2011-10-31
@N3K

db.transactions.update({}, {$set: {viewsMonth: 0}})

G
g00d, 2011-10-31
@g00d

this might help

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question