A simple JSON database for PXE.js.
Install @pxe/database
.
# NPM
npm i @pxe/database vlds
# Yarn
yarn add @pxe/database vlds
These are all @pxe/database
module methods, events and declarations.
Database
path?: string
: The database path.Create a database instance.
db.remove
collectionName: string
: The name of the collection to be removed.Remove a collection from the database.
db.clear
Clear the database.
db.collect
T
: The collection type.name: string
: The collection name.validator: valids.Validator
: A type validator from package vlds
.Create a new database collection.
The class returns by db.collect
.
Collection
data: T
: The data.Create an object with the specified value if validate successfully.
item.save
Save or resave the collection to the database.
item.del
Delete the collection from the database.
item.setValue
value: T
: Value to be set to the collection.Set the value to the collection and save to the database.
Collection.remove
id: string
: ID of object to be removed.Delete object from collection by ID.
Collection.removeAll
o: any
: Key that will be matched to objects.count?: number
: Number of objects to be removed.Delete all objects the match o
in the collection. Delete count
objects if specified.
Collection.select
id: string
: ID of object to be selected.Select a collection by ID.
Collection.find
o: any
: Key that will be matched to objects.count?: number
: Number of objects to be removed.Find a collection that matches o
. Find count
number of collections if specified.
Collection.findOne
o: any
: Key that will be matched to objects.Find a single colelction that matches o
.
Collection.update
o: any
: Key that will be matched to objects.value: T
: Value to update the collection with.rewrite?: boolean
: Overwrites the object when true.Update the first collection that matches o
with the new value
.
Collection.updateID
id: string
: ID of object to be updated.value: T
: Value to update the collection with.rewrite?: boolean
: Overwrites the object when true.Update an item by its ID.
Update a collection by ID with the new value
.
db.path
string
The specified database path. Can be undefined
.