Last updated:
0 purchases
scientisst db
scientisst_db #
Open source Flutter plugin that implements a NoSQL document-based local database.
The syntax of this package is similar to other well-known databases, organizing its data in collections and documents.
Made by the ScientISST team.
Installation #
dependencies:
flutter:
sdk: flutter
scientisst_db: ^0.1.2
copied to clipboard
Architecture #
The database stores data in the Applications Documents Directory, provided by path_provider.
The database directory is stored in a root folder called scientisst_db.
The first layer is constituted only by collections, which have their corresponding directory. Each collection directory is constituted by three separate folders: collections, documents, and metadata. The collection children documents are stored in the documents folder, where each document has its separate file with a filename corresponding to its ObjectId. The ObjectId is generated according to MongoDB's standard or can be an arbitrary String. The document data is stored in a JSON formatted text file.
Each document has a corresponding metadata file which is stored in the metadata folder inside the collection directory, with a filename equal to the ObjectId, encoded also in the JSON format.
A document can store collections (sub-collections), which are stored in a folder inside the collections directory under the parent collection directory. This folder has the same filename as the document ObjectId and it follows the same collection structure.
Examples #
See the full example here.
Some basic examples:
Add a document to a collection:
DocumentReference doc = await ScientISSTdb.instance.collection("movies").add(
{
"title": "Eternal Sunshine of the Spotless Mind",
"year": 2004,
"characters": [
"Joel",
"Clementine",
],
},
);
copied to clipboard
Update a document:
await doc.update(
{
"title": "Hello world",
},
);
copied to clipboard
Delete a document:
await ScientISSTdb.instance.collection("movies").document("507f1f77bcf86cd7994ca120").delete();
copied to clipboard
Get all documents from a collection:
await ScientISSTdb.instance.collection("movies").getDocuments();
copied to clipboard
Order documents by field value:
await ScientISSTdb.instance
.collection("movies")
.orderBy("year", ascending: false)
.getDocuments();
copied to clipboard
Future #
Improve the Exceptions thrown.
If you have any suggestion or problem, let us know and we'll try to improve or fix them.
License #
GNU General Public License v3.0, see the LICENSE file for details.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.