diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..70ea15e --- /dev/null +++ b/CHANGELOG.md @@ -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 diff --git a/DOCS.md b/DOCS.md index f19d81b..71419e4 100644 --- a/DOCS.md +++ b/DOCS.md @@ -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 @@ -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 @@ -44,10 +90,12 @@ - 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 @@ -55,20 +103,32 @@ - 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 @@ -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 diff --git a/README.md b/README.md index 61a52ff..d2ac65c 100644 --- a/README.md +++ b/README.md @@ -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', [