@@ -15,16 +15,18 @@ Previously, TinyBase supported `string`, `number`, `boolean`, and (since v7.0)
1515directly in a Store.
1616
1717``` js
18- const richStore = createStore ().setRow (' pets' , ' fido' , {
18+ import {createStore } from ' tinybase' ;
19+
20+ const store = createStore ().setRow (' pets' , ' fido' , {
1921 species: ' dog' ,
2022 traits: {friendly: true , energetic: true },
2123 vaccinations: [' rabies' , ' distemper' , ' parvovirus' ],
2224});
2325
24- console .log (richStore .getCell (' pets' , ' fido' , ' traits' ));
26+ console .log (store .getCell (' pets' , ' fido' , ' traits' ));
2527// -> {friendly: true, energetic: true}
2628
27- console .log (richStore .getCell (' pets' , ' fido' , ' vaccinations' ));
29+ console .log (store .getCell (' pets' , ' fido' , ' vaccinations' ));
2830// -> ['rabies', 'distemper', 'parvovirus']
2931```
3032
@@ -36,17 +38,19 @@ them as native JavaScript values.
3638Schemas also gain ` object ` and ` array ` as valid types:
3739
3840``` js
39- const richSchemaStore = createStore () .setTablesSchema ({
41+ store .setTablesSchema ({
4042 pets: {
4143 species: {type: ' string' },
4244 traits: {type: ' object' , default: {}},
4345 vaccinations: {type: ' array' , default: []},
4446 },
4547});
4648
47- richSchemaStore .setRow (' pets' , ' fido' , {species: ' dog' });
48- console .log (richSchemaStore .getRow (' pets' , ' fido' ));
49+ store .setRow (' pets' , ' fido' , {species: ' dog' });
50+ console .log (store .getRow (' pets' , ' fido' ));
4951// -> {species: 'dog', traits: {}, vaccinations: []}
52+
53+ store .delSchema ();
5054```
5155
5256Note that TinyBase does not deeply validate the contents of objects or arrays
@@ -62,8 +66,7 @@ registered to fire before data is written to the Store, allowing you to modify,
6266validate, or even reject changes before they take effect.
6367
6468``` jsx
65- import {createMiddleware , createStore } from ' tinybase' ;
66- const store = createStore ();
69+ import {createMiddleware } from ' tinybase' ;
6770
6871const middleware = createMiddleware (store);
6972middleware .addWillSetCellCallback ((tableId , rowId , cellId , cell ) => {
@@ -86,12 +89,6 @@ returning `undefined`. In conjunction with schemas, Middleware provides a
8689powerful way to enforce data integrity and implement complex data
8790transformations - and it should work in synchronization environments too.
8891
89- As well as intercepting changes with the ` WillSet* ` callbacks, Middleware can
90- also provide a post-transaction DidSetRowCallback callback. This fires once per
91- changed Row after all writes in a transaction have settled, including writes
92- made by mutating listeners, hence providing you ultimate definitive control over
93- the rows written to a Table.
94-
9592Many, many thanks to [ Brandon Mason] ( https://github.com/bitmage ) for designing
9693and implementing this concept. Despite the major version number, we trust there
9794are no breaking changes in this release. But please let us know if you find any!
0 commit comments