Skip to content

Release 1.3.0

Compare
Choose a tag to compare
@ECorreia45 ECorreia45 released this 17 Jun 21:54
· 45 commits to develop since this release

Browser storage interface for IndexedDB, WebSQL, LocalStorage, and in-memory- data with basic Schema and data validation.

// Define schema TS type
import {ClientStore, Schema} from "client-web-storage";

interface ToDo extends Schema.DefaultValue {
    name: string;
    description: string;
    complete: boolean;
}

// create and define schema
const todoShema = new Schema<ToDo>("todo");

todoShema.defineField("name", String, {required: true});
todoShema.defineField("description", String);
todoShema.defineField("complete", Boolean);

// create and use the store
const todoStore = new ClientStore("todos", todoShema);

todoStore.createItem({
    name: "Go to Gym" // only name is required
});

/*  Creates item in the store
{
  id: 3284732894792342, // generated id
  name: "Go to Gym",
  description: "",
  complete: false,
  createdDate: "January, 4th 2022",
  lastUpdatedDate: "January, 4th 2022",
}
*/

What's Changed

Full Changelog: https://github.com/beforesemicolon/client-web-storage/commits/1.3.0