Update records

The update method is used to modify records, it always has to be used with the where method and a filter criteria so we know what should be updated. In  order to select a field, you need to import the Field Module first. Creating a filter using the conditional methods below provide you with a lot of flexibility on when a record should be updated.

You can use the following conditional methods to create a filter:

  • isGreaterThan
  • isLessThan
  • isEqualTo
  • isDifferentFrom
  • isEqualOrGreaterThan
  • isEqualOrLessThan
  • isNull
  • isNotNull
  • isInArray
  • isNotInArray
  • isLike
  • satisfiesRegexp
  • isBetween

Example:


import { field } from "SDK location"
[..]
let posts = dataModule.dataset("posts");
const filter = field("id").isInArray([1, 2]);
posts.update({
  title: "Changing title",
}).where(filter).execute().then(() => {
  // the elements that fill the criteria now have been changed
}).catch( (error) => {
  // you can see the error info here, if something goes wrong
});

Advanced users:

In order to obtain deeper insights, please visit the API reference