• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# EJDB2 Typescript example project
2
3```ts
4import { EJDB2 } from 'ejdb2_node';
5
6async function run() {
7  const db = await EJDB2.open('example.db', { truncate: true });
8
9  var id = await db.put('parrots', {'name': 'Bianca', 'age': 4});
10  console.log(`Bianca record: ${id}`);
11
12  id = await db.put('parrots', {'name': 'Darko', 'age': 8});
13  console.log(`Darko record: ${id}`);
14
15  const q = db.createQuery('/[age > :age]', 'parrots');
16
17  for await (const doc of q.setNumber('age', 3).stream()) {
18    console.log(`Found ${doc}`);
19  }
20
21  await db.close();
22}
23
24run();
25```
26
27## Build and run
28
29```sh
30cd ./example
31yarn install
32yarn run start
33```