deta 0.0.3+1 copy "deta: ^0.0.3+1" to clipboard
deta: ^0.0.3+1 copied to clipboard

A Dart package to interact with the HTTP API of the free services of the Deta plataform.

Deta #

codecov style: very good analysis pub package License: MIT


A Dart package to interact with the HTTP API of the free services of the Deta plataform.

๐Ÿšจ WARNING ๐Ÿšจ This client should only be used on the server side.


Index #

Getting Started #

Check the full example here.

Install #

Add to dependencies on pubspec.yaml:

dependencies:
    deta: <version>
copied to clipboard

Usege #

We declare class Deta, which receives our private credential as a parameter. The client parameter can receive two different implementations DioClientDetaApi or HttpClientDetaApi, you need to add to its dependencies the one you prefer.

  final deta = Deta(projectKey: 'projectKey', client: DioClientDetaApi(dio: Dio()));
copied to clipboard

๐Ÿšจ WARNING ๐Ÿšจ Your projectKey is confidential and meant to be used by you. Anyone who has your project key can access your database. Please, do not share it or commit it in your code.

DetaBase #

DetaBase is a fully-managed, fast, scalable and secure NoSQL database with a focus on end-user simplicity.

We define our DetaBase, with witch we are going to interact through the base method that receives the name of the DetaBase as a parameter. In case not exist it will be created instantly on first use, you can create as many DetaBase as you need.

A DetaBase instance is a collection of data, not unlike a Key-Value store, a MongoDB collection or a PostgreSQL/MySQL table.

  final detabase = deta.base('lenguages');
copied to clipboard

Methods

put

Save an item. It will update an item if the key already exists.

  await detabase.put({
    'key': 'dart-g',
    'name': 'Dart',
    'description':
        'Dart is a general-purpose programming language that adds strong '
            'support for modularity, co-variant return types, and a strong '
            'emphasis on type safety.',
    'creator': 'Google',
    'year': 2012,
  });
copied to clipboard
putMany

Saves a list the elements, this list can only have a maximum of 20 element.

  await detabase.putMany(
    items: lenguages.map((lenguage) => lenguage.toJson()).toList(),
  );
copied to clipboard
insert

Saves an element like put, with the difference that if this element exists in DetaBase it will throw an DetaObjectException. The key required that are part of the elemet to be saved.

  await detabase.insert({
    'key': 'r-f',
    'name': 'R',
    'description': 'R is a programming language and software environment '
        'for statistical computing and graphics.',
    'creator': 'R Foundation',
    'year': 1995,
  });
copied to clipboard
update

Update the element from the supplied key, you have to pass the whole element, both the updated and unchanged parameters.

  await detabase.update(
    key: 'ruby-ym',
    item: <String, dynamic>{
      'key': 'ruby-ym',
      'name': 'Ruby',
      'description': 'Ruby is a dynamic, open source, general-purpose '
          'programming language with a focus on simplicity and productivity.',
      'creator': 'Yukihiro Matsumoto',
      'year': 1995,
    },
  );
copied to clipboard
get

Get a spesific element form the key.

  final item = await detabase.get('dart-g');
copied to clipboard
delete

Delete a spesific element from the key.

  final wasDeleted = await detabase.delete('ruby');
copied to clipboard
fetch

Return all saved items if no query is specified.

  final all = await detabase.fetch();
copied to clipboard

Return all element that matched the indicated query.

final result = await detabase.fetch(
  query: [DetaQuery('year').lessThanOrEqualTo(2000).and('name').prefix('C')],
);
copied to clipboard

Running Tests ๐Ÿงช #

To run all unit tests use the following command:

flutter test --coverage --test-randomize-ordering-seed random

copied to clipboard

To view the generated coverage report you can use coverde.

# Generate Coverage Report
$ coverde report
copied to clipboard

A Very Good Project created by Very Good CLI.

7
likes
160
points
10
downloads

Publisher

unverified uploader

Weekly Downloads

2024.06.21 - 2025.01.03

A Dart package to interact with the HTTP API of the free services of the Deta plataform.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

client_deta_api

More

Packages that depend on deta