objective_db 0.0.3+3 copy "objective_db: ^0.0.3+3" to clipboard
objective_db: ^0.0.3+3 copied to clipboard

JSON based Database

Objective DB #

JSON based Database. #

Hecho en 🇵🇷 por Radamés J. Valentín Reyes

Status #

Experimental/Under Development

Importing #

import 'package:objective_db/objective_db.dart';

About the project #

  • The program will throw errors every time an error is encountered or a forbidden operation is attempted(such as editing the uuid).
  • uuid's in this project are composed of 40 alphanumeric characters.
  • All data is stored as .json and returned as Map<String,dynamic>
  • When insertin Map<String,dynamic> a new file will be created and a reference to it will be stored in the parent .json object.

Functions, classes and methods #

Entry #

Entry class is the root of the file structure.

Entry entry = Entry(dbPath: "./database");

Select method #

returns a DbObject which contains many more useful methods like insert and delete.

Entry entry = Entry(dbPath: "./database");
DbObject dbObject = entry.select();

Insert method #

If the value is a double, int or String the insert method will add the key to the selected Map, if the key already exists the value will be replaced. If you you try to insert a Map a new file will be created and a reference to the file will be generated. If the value you try to replace has a Map assigned to it you will get an error. If you try to insert a List<Map<String,dynamic>> new files and references will be generated.

Entry entry = Entry(dbPath: "./database");
entry.select().insert(
  key: "Stores",
  value: [
    {
      "Name": "Frappé inc",
      "balance": 18.59,
    },
    {
      "Name": "Rica Pizza",
      "balance": 19000,
    },
  ],
);

View method #

Returns a Map<String,dynamic> with parsed .json contents. You will see that the only property that stored Map<String,dynamic> contains is "uuid". The reason is that this are references not the actual Object.

Entry entry = Entry(dbPath: "./database");
List<DbObject> objects = entry.select().selectMultiple(
  key: "Stores",
);
for(DbObject object in objects){
  print(object.view());
}

Delete method #

Deletes object property if pointing to a key with a value of type int, double or String. If your delete target is an object reference(Map<String,dynamic> with uuid) deletes the object and all linked/referenced objects(children).

Entry entry = Entry(dbPath: "./database");
List<DbObject> objects = entry.select().selectMultiple(
  key: "Stores",
);
DbObject pizzaPlace = objects.firstWhere((element)=> (element.view()["Name"] as String).toLowerCase().contains("pizza"));
entry.select().delete(
  key: "Stores", 
  uuid: pizzaPlace.uuid,
);
2
likes
0
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

JSON based Database

License

unknown (license)

Dependencies

power_plant

More

Packages that depend on objective_db