TinyBase logoTinyBase

delValue

The delValue method lets you remove a single Value from a Store.

delValue(valueId: string): this
TypeDescription
valueIdstring

The Id of the Value in the Row.

returnsthis

A reference to the Store.

If there is a ValuesSchema applied to the Store and it specifies a default value for this Value Id, then deletion will result in it being set back to its default value.

Examples

This example removes a Value from a Store without a ValuesSchema.

import {createStore} from 'tinybase';

const store = createStore().setValues({open: true, employees: 3});
store.delValue('employees');

console.log(store.getValues());
// -> {open: true}

This example removes a Value from a Store with a ValuesSchema that defaults its value.

import {createStore} from 'tinybase';

const store = createStore()
  .setValues({open: true, employees: 3})
  .setValuesSchema({
    open: {type: 'boolean', default: false},
    employees: {type: 'number'},
  });
store.delValue('open');

console.log(store.getValues());
// -> {open: false, employees: 3}

Since

v3.0.0