S
S
Stanislav Menshov2019-07-24 16:08:09
MongoDB
Stanislav Menshov, 2019-07-24 16:08:09

How to automatically update a field in a collection?

Strictly speaking, this is a trigger like RDMBS.
There is a collection of products with fields:

  • _id (Object ID)
  • quantity (number)
  • enabled (Boolean)

When the products.quantity field is updated to the value = 0 , the products.enabled field was set to false automatically depending on the products.quantity and also products.enabled = true if products.quantity > 0.
Is this possible using the MongoDb database?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Menshov, 2019-07-29
@SWEBB

Perhaps this should be done at the application level?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question