* Set a Property, Value combination and perform a validation. Will throw if * property is not valid for the datatype. Will fetch the datatype if it's not * available. Adds the property to the commitbuilder.
(
prop: string,
value: JSONValue,
store: Store,
/**
* Disable validation if you don't need it. It might cause a fetch if the
* Property is not present when set is called
*/
validate = true,
)
| 290 | * available. Adds the property to the commitbuilder. |
| 291 | */ |
| 292 | async set( |
| 293 | prop: string, |
| 294 | value: JSONValue, |
| 295 | store: Store, |
| 296 | /** |
| 297 | * Disable validation if you don't need it. It might cause a fetch if the |
| 298 | * Property is not present when set is called |
| 299 | */ |
| 300 | validate = true, |
| 301 | ): Promise<void> { |
| 302 | if (validate) { |
| 303 | const fullProp = await store.getProperty(prop); |
| 304 | validateDatatype(value, fullProp.datatype); |
| 305 | } |
| 306 | this.propvals.set(prop, value); |
| 307 | // Add the change to the Commit Builder, so we can commit our changes later |
| 308 | this.commitBuilder.set[prop] = value; |
| 309 | // If the property has been removed before, undo that |
| 310 | this.commitBuilder.remove = this.commitBuilder.remove.filter( |
| 311 | item => item == prop, |
| 312 | ); |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * Set a Property, Value combination without performing validations or adding |
no test coverage detected