0

I am trying to add a field to all documents in the database, but I am not sure how to do that. Here is my database

      const db = client.schema

How would I update all documents and add a field called tiks (number) in it?

0

1 Answer 1

4
db.yourCollection.update(
  {},
  { $set: {"newField": 1} },
  false,
  true
)

Parameters

  1. Collection to update since you want all {}
  2. Field to set
  3. Upsert - only add when it is not there hence false
  4. Multi - update multiple documents if matches to query hence true
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.