jab_db 1.0.0 jab_db: ^1.0.0 copied to clipboard
A Dart package for interacting with JabDB
Flutter JabDB #
Flutter JabDB is a Dart package designed for Flutter applications that need to interact with a JabDB backend. It provides a convenient way to perform CRUD operations on a JabDB server from your Flutter app.
Installation #
To use Flutter JabDB in your Flutter project, add the following dependency to your pubspec.yaml
file:
dependencies:
flutter_jabdb: ^1.0.0
Then, run:
bash
flutter pub get
Usage
To get started, import the flutter_jabdb.dart file in your Dart code:
dart
import 'package:flutter_jabdb/flutter_jabdb.dart';
Initialization
Create an instance of the FlutterJabDB class with the appropriate API base URL and API key:
dart
FlutterJabDB flutterJabDB = FlutterJabDB(apiBaseUrl: 'https://your-api-endpoint.com', apiKey: 'your-api-key');
Fetch All Collection Names
dart
List<String> collections = await flutterJabDB.getAllCollections();
print('All Collections: $collections');
Fetch Data from a Collection
dart
List<Map<String, dynamic>> data = await flutterJabDB.getCollectionData('users', options: {
'filters': {'age': {'\$gte': 18}},
'sortField': 'name',
'sortOrder': 'asc',
'page': 1,
'pageSize': 10,
});
print('Data from Users Collection: $data');
Get Entry by ID
dart
Map<String, dynamic> entry = await flutterJabDB.getEntryById('users', '123');
print('Entry: $entry');
Search Entity by Field
dart
List<Map<String, dynamic>> matchingEntities = await flutterJabDB.searchEntityByField('users', 'name', 'John Doe');
print('Matching Entities: $matchingEntities');
Add Data to Collection
dart
Map<String, dynamic> newData = {'name': 'John Doe', 'age': 25};
await flutterJabDB.addDataToCollection('users', newData);
print('Data added successfully');
Delete Data from Collection
dart
await flutterJabDB.deleteDataFromCollection('users', '123');
print('Data deleted successfully');
Update Data in Collection
dart
Map<String, dynamic> updatedData = {'name': 'Updated Name', 'age': 30};
await flutterJabDB.updateDataInCollection('users', '123', updatedData);
print('Data updated successfully');
License
This project is licensed under the MIT License - see the LICENSE file for details.
vbnet
Make sure to replace the placeholder values like `https://your-api-endpoint.com`, `your-api-key`, etc., with the actual values relevant to your project.