<commit_before>import 'package:ejdb2_dart/ejdb2_dart.dart';

void main() async {
  final db = await EJDB2.open('hello.db', truncate: true);

  var q = db.createQuery('@mycoll/*');
  assert(q != null);
  assert(q.collection == 'mycoll');
  assert(q.db != null);

  final id = await db.put('mycoll', {'foo': 'bar'});
  assert(id == 1);

  dynamic error;
  try {
    await db.put('mycoll', '{"');
  } on EJDB2Error catch (e) {
    error = e;
    assert(e.code == 86005);
    assert(e.message == 'Unquoted JSON string (JBL_ERROR_PARSE_UNQUOTED_STRING)');
  }
  assert(error != null);

  var json = await db.get('mycoll', id);
  assert(json == '{"foo":"bar"}');

  await db.put('mycoll', {'foo': 'baz'});

  final list = await db.createQuery('@mycoll/*').execute(limit: 1).toList();
  print(list);

  var first = await db.createQuery('@mycoll/*').first();
  assert(first != null);
  assert(first.isPresent);
  assert(first.value.json == '{"foo":"baz"}');<commit_msg>* ejdb2_dart_test minors<commit_after>import 'package:ejdb2_dart/ejdb2_dart.dart';

void main() async {
  final db = await EJDB2.open('hello.db', truncate: true);

  var q = db.createQuery('@mycoll/*');
  assert(q != null);
  assert(q.collection == 'mycoll');
  assert(q.db != null);

  final id = await db.put('mycoll', {'foo': 'bar'});
  assert(id == 1);

  dynamic error;
  try {
    await db.put('mycoll', '{"');
  } on EJDB2Error catch (e) {
    error = e;
    assert(e.code == 86005);
    assert(e.message == 'Unquoted JSON string (JBL_ERROR_PARSE_UNQUOTED_STRING)');
  }
  assert(error != null);

  var json = await db.get('mycoll', id);
  assert(json == '{"foo":"bar"}');

  await db.put('mycoll', {'foo': 'baz'});

  final list = await db.createQuery('@mycoll/*').execute(limit: 1).toList();
  assert(list.length == 1);

  var first = await db.createQuery('@mycoll/*').first();
  assert(first != null);
  assert(first.isPresent);
  assert(first.value.json == '{"foo":"baz"}');
{'fraction_non_alphanumeric': 0.21377183967112023, 'fraction_numerical': 0.012332990750256937, 'mean_word_length': 4.150793650793651, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4036604', 'n_tokens_mistral': 754, 'n_tokens_neox': 725, 'n_words': 150}