NestEggDB

NestEggDB is a lightweight, file-based NoSQL database for Flutter, using Nest (database) and Egg (document/data entry). It supports transactions, queries, and ordered data storage.

Features

  • Manage data with Nests (collections) and Eggs (entries).
  • Perform atomic transactions.
  • Filter and sort data with queries.
  • Preserve data order.
  • Handle hierarchical data with Sub-Eggs.

Installation

Add to pubspec.yaml:

dependencies:
  egg_nest_db: ^0.0.3

Run:

flutter pub get

Usage

import 'package:egg_nest_db/nest.dart';

// Initialize a Nest
final nest = Nest(path: '/path/to/database');
final collection = nest.eggCollection('myCollection');

// Add an Egg
collection.addEgg({'id': '1', 'name': 'First Egg', 'content': 'This is the first egg.'});

// Retrieve an Egg
final egg = collection.getEgg('1');
print('Egg content: ${egg?.data}');

// Update an Egg
collection.updateEgg('1', {'content': 'Updated content for the first egg.'});

// Delete an Egg
collection.deleteEgg('1');

// Perform a Transaction
nest.runTransaction((transaction) {
  transaction.add(collection, {'id': '2', 'name': 'Second Egg', 'content': 'This is the second egg.'});
});

// Query Data
final query = Query(collection).where('name', 'isEqualTo', 'First Egg').orderBy('id');
final results = query.get();
for (var result in results) {
  print(result);
}

// Get All Data with Sub-Eggs
print(collection.getAllData());