bagel_db 0.1.6 copy "bagel_db: ^0.1.6" to clipboard
bagel_db: ^0.1.6 copied to clipboard

outdated

Dart plugin to retrieve and update data on BagelDB. This library allows you to build a backend in a matter of minutes, make REST API requests and manage your content easily

example/main.dart

// Copyright 2020 Bagel Studio ltd. All rights reserved.
// For an example app, see https://github.com/bagelstudio/bagel_pizza

import 'dart:io';
import 'package:bagel_db/bagel_db.dart';

// create an instance of BagelDB
BagelDB bagelDB = BagelDB('BearerTestToken'); // replace with your project id

// a var that will hold the response from BagelDB


// get data using Builder pattern
void getFromBagelDB() async {
  // simple get request
  BagelResponse testItems = await bagelDB.collection('testItems').get();

  // get with query
  BagelResponse developers = await bagelDB.collection('testItems').query('position', '=', 'developer').query('age', '>', '27').get();

  // sort the data by parameter
  BagelResponse sortedTestItems = await bagelDB.collection('testItems').sortBy('age').get();

  // sort with order
  BagelResponse sortedDescTestItems = await bagelDB.collection('testItems').sortBy('age', orderTerm: 'desc').get();

  // define how many results will be in each page
  BagelResponse testItems2 = await bagelDB.collection('testItems').perPage(2).get();

  // include all the details for item
  BagelResponse deepTestItems = await bagelDB.collection('testItems').everything().get();

  // get a specific item
  BagelResponse oneItem =  await bagelDB.collection('testItems').item('5dr22f010a1466a13e2f967a' /*replace with your item id*/).get();
}

// post item. Post returns the id of item that created
void postToBagelDB() async {
  // post item to BagelDB
  await bagelDB
      .collection('testItems')
      .post(item: {'name': 'Baz', 'age': 25, 'position': 'CTO'} /* replace with your item */);
}

// put item
void putInBagelDB() async {
  // post item to BagelDB
  await bagelDB.collection('testItems').item('5dr22f010a1466a13e2f967a').put(item: {
    'name': 'Baz',
    'age': 34,
    'position': 'CEO',
  });
}

void deleteFromBagelDB() async {
  await bagelDB.collection('testItems').item('5dr22f010a1466a13e2f967a').delete();
}

// uploading image
void uploadImage() async {
  File image = File('/Users/userName/Desktop/photo-test.jpeg');
  await bagelDB.collection("users").item("3423432").uploadImage("profilePic", image);
}
10
likes
0
pub points
26%
popularity

Publisher

verified publisherbageldb.com

Dart plugin to retrieve and update data on BagelDB. This library allows you to build a backend in a matter of minutes, make REST API requests and manage your content easily

Homepage

License

unknown (license)

Dependencies

dio, flutter

More

Packages that depend on bagel_db