smart_arrays_dbstore 2.0.6
smart_arrays_dbstore: ^2.0.6 copied to clipboard
Storing 1D or 2D arrays with their metadata inside indexedDB databases on the local device (for WEB applications).
Smart Arrays Database Store #
What the package can do for you #
-
This package was designed for Web applications which need to store data on the local device (PC, tablet, phone) over a longer time period, e.g. to view or process the data by a Web app during multiple sessions.
-
The package is capable of saving one- and two-dimensional arrays of double values and String-valued maps in databases, optionally along with metadata containing additional information about the actual array data.
-
Arrays with their metadata are considered as "datasets" of type
DSet. ADSetcan be created from arrays and metadata using this package. -
Each dataset
DSetis stored in its own database of typeIndexedDBunder the browser. The user must define its name (similar as one would do it under a file system) for later retrieval. -
Many datasets, even of big size (e.g. array sizes of several megabytes) may be stored. The exact limits per origin are browser dependent. Browsers derive their limits from the available storage using their own algorithms.
-
The package was tested using the following browsers: Chrome under Windows, Linux, Android, iOS. Safari under iOS.
-
Datset sets will remain stored until
- they are explicitely deleted by using respective API functions provided by this package.
- the user deleted the browser data via respective functions of the operating system or from the browser's advanced settings menu.
- the browser itself decided to delete data. This may happen if storage on the local machine is running tight ("storage pressure"). However: Some browsers (e.g. Chrome) support "persistent" data. This package provides a function 'DSetDB.persistent' requesting data to make the storage persistent ("durable") if supported. You must check with your browser whether and under which conditions persistence is granted. For Chrome you may e.g. check the site
https://developers.google.com/web/fundamentals/instant-and-offline/web-storage/offline-for-pwa.
-
This packages utilizes
IndexedDBdatabases managed by the browser. Their technical storage method and storage location on a device is browser dependent, and also depends on the origin from which the Web app is served. For Chrome, you can list the databases by enteringchrome://indexeddb-internalsinto the browser's address field.
The major API functionalities #
-
Class
DSetto create a datset from arrays and its metadata: -
Class
DSkeyto create a datset key (dataset identifier) under which a dataset will be stored. -
Class
DSetStore, a handler to store datasets on the device, to load stored datasets, to delete, copy, rename datasets, to obtain a list (directory) of stored datasets, to save information common to all datasets in a global store, to classify datasets intoprojects. -
Class
DSetDBto initially create aDSetStorerequired to apply the functionalities above. -
Basic usage to store a datset:
- create a dataset of type
DSetfrom your array and metadata (constructorDSet). - create a
DSkeyidentifier for your data in the store (methodDSKey.create) - create a
DSetStorestorage handler (methodDSetDB.createDSetStore). - invoke
DSetStore.dsSaveto store the data
- create a dataset of type
-
Basic usage to load a stored datset:
- create a
DSkeyidentifier for the data you want to load from the store (methodDSKey.create) - create a
DSetStorestorage handler (methodDSetDB.createDSetStore). - invoke
DSetStore.dsLoadto load stored data
- create a
-
Basic usage to find out which datasets are available in the store:
- create a
DSetStorestorage handler (methodDSetDB.createDSetStore). - invoke
DSetStore.projectsGetto get a list of all projects. - For each project, invoke
DSetStore.dskeysWithProjectto get a list of the dataset keys of the dataset stored under this project. You will use then such a key to load the data. Or you can build a GUI displaying the projects with their datasets.
- create a
Please check the provided example for details.
Detailed API
Please view the detailed API documentation in the API reference of this package (sidebar at the right of this page).
Related packages #
smart_arrays_base: Basic functions for 1D and 2D arrays
smart_arrays_numerics: Numerics with 1D and 2D arrays
smart_arrays_compress: Compress 1D and 2D arrays to a smaller size.
smart_arrays_plot_polyline: Plot 1D arrays as polyline along with axes and more.
smart_arrays_peaks: Detect peaks in 1D and 2D arrays.
smart_lorentz-gauss: Compute Lorentz-Gauss (pseudo-Voigt) line shapes.