couchdb 0.4.3 copy "couchdb: ^0.4.3" to clipboard
couchdb: ^0.4.3 copied to clipboard

outdated

Library for interacting with CouchDB from both a server and browser environment

example/README.md

Server #

import 'package:couchdb/couchdb.dart';

Future<void> main() async {
  final client = CouchDbClient(username: 'name', password: 'password');
  final dbModel = DatabaseModel(client);
  final docModel = DocumentModel(client)

  try {
    final DbResponse commonResponse = await dbModel.allDocs('some_db');
    final DatabaseModelResponse response1 = commonResponse.databaseModelResponse();

    for (var i in response1.rows) {
      // Some code here
    }

    final DbResponse response2 = await docModel.doc('another_db', 'some_id');

    var thing = response2.json['some_attribute'];

  } on CouchDbException catch (e) {
    print('$e - error');
  }
}

Browser #

import 'dart:html';

import 'package:couchdb/couchdb.dart';

Future<void> main(List<String> args) async {
  final ButtonElement btn = querySelector('#data');
  final DivElement output = querySelector('#output');

  final c = CouchDbClient(username: 'name', password: 'pass', cors: true);
  final dm = DocumentModel(c);

  btn.onClick.listen((event) async {
  try {
    final DbResponse commonResponse = await dbModel.doc('some_db', 'some_doc_id');
    final DocumentModelResponse response1 = commonResponse.documentModelResponse();

    final Map<String, Object> doc = response1.doc;

    // Some code here

    // There properties are extracted from [doc] in order to gets direct access
    final String id = response1.id;
    final String rev = response1.rev;
    final Object attachment = response1.attachment;

    // Another code here

  } on CouchDbException catch (e) {
      window.console.log('${e.code} - error');
    }
  });
}
20
likes
0
pub points
10%
popularity

Publisher

unverified uploader

Library for interacting with CouchDB from both a server and browser environment

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

crypto, http, meta

More

Packages that depend on couchdb