Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
update readme/docs; add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelFedora committed Aug 21, 2019
1 parent 2b85f71 commit 154f33a
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 5 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# v2.0

Moved from `reql-sqlite3` because we are now supporting multiple databases!

# Breaking

- Changed how Databases are initialized
- You now import either `createSQLite3Database` or `createPostgreDatabase`
- String Datum `includes` function has been renamed to `substr` to not be confused with Array functions

# Changes

- :tada: Added PostgreSQL support! :tada:
- `expr` can now be imported by anyone to create "static" expressions, for use in filters or otherwise
- Added the ability to fork statements
- Statements are saved to the initial variable in order to save memory and processing power in creating
tons of new objects. The query queue will only be emptied on an action (i.e. `run`, `delete`, etc), but if
you want to keep it then use `fork()` to return a clone and `run()` off of that instead.
- Added Array abilities to Datums (i.e. not just streams now)
- `count`
- `limit`
- `difference`
- `contains`
- `filter`
- `pluck`
- `map`
- Added the ability to close Database connections (`db.close()`);

# v1.0

Initial Release
74 changes: 70 additions & 4 deletions DOCS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,49 @@

# Docs

### Initializing Databases

Databases can be initialized by importing their factory function from the package.

#### SQLite3

```typescript
import { createPostgreDatabase } from 'reql-bridge';

const db = await createPostgreDatabase({
filename: ':memory:',
logger: 'app.sqlite3'
});

await db.createTable('my-table').run();
```

The config can contain a `logger` entry for whatever log4js category you want it to use,
and an optional `filename` entry to pass a filename to create/use as the database
(`:memory:` by default).

#### PostgreSQL

```typescript
import { createPostgreDatabase } from 'reql-bridge';

const db = await createPostgreDatabase({
username: 'my-username',
password: 'keyboardcat'
});

await db.createTable('my-table').run();
```

The config can contain a `logger` entry for whatever log4js category you want it to use,
a `client` entry if you want to manually pass a `node-postgres` client to it, or any of
the options for creating a Pool with `node-postgres`.

### Manipulating Databases

- close
- database.close() -> void

### Manipulating Tables

- tableCreate
Expand Down Expand Up @@ -33,6 +78,7 @@
- table.filter(predicate | object) -> selection
- selection.filter(predicate | object) -> selection
- stream.filter(predicate | object) -> stream
- array.filter(predicate | object) -> array

### Joins

Expand All @@ -44,31 +90,45 @@
- table.map(predicate) -> stream
- selection.map(predicate) -> stream
- stream.map(predicate) -> stream
- array.map(predicate) -> array
- limit
- table.limit(n) -> stream
- selection.limit(n) -> stream
- stream.limit(n) -> stream
- array.limit(n) -> array

### Aggregation

- count
- table.count() -> number
- selection.count() -> number
- stream.count() -> number
- array.count() -> number
- distinct
- table.distinct() -> stream
- selection.distinct() -> stream
- stream.distinct() -> stream
- contains
- table.contains(item) -> boolean
- selection.contains(item) -> boolean
- stream.contains(item) -> boolean
- array.contains(item) -> boolean

### Document Manipulation

- table.pluck(...fields) -> stream
- pluck
- table.pluck(...fields) -> stream
- selection.pluck(...fields) -> stream
- stream.pluck(...fields) -> stream
- array.pluck(...fields) -> array
- difference
- array.difference(array) -> array
- () (bracket)
- table(attribute) -> selection
- selection(attribute) -> selection
- stream(attribute) -> stream
- singleSelection(attribute) -> value
- datum(attribute) -> value
- *use `pluck` + `map` with tables/selections/streams*

### String manipulation

Expand Down Expand Up @@ -114,9 +174,15 @@
- not
- bool.not() -> bool

### Dates and times

Not supported - make them a number!

### Control structures

- expr(value) -> value

### The rest (unsupported)

- Dates and times (*make them a number*)
- Control structures
- Geospatial commands
- Administration
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*ReQL(-like) interpreter for a multitude of databases*

```typescript
import { create as createReQLSQLite3DB } from 'reql-bridge/sqlite3';
import { createSQLite3Database } from 'reql-bridge';

const db = await create({ filename: ':memory:' });
await db.tableCreate('my-table', [
Expand Down

0 comments on commit 154f33a

Please sign in to comment.