Skip to content

Commit

Permalink
fix(sqlite-driver): use environment variable for default path
Browse files Browse the repository at this point in the history
  • Loading branch information
darlanalves committed Jul 9, 2023
1 parent c40f540 commit 4529912
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Expand Up @@ -28,3 +28,23 @@ const users = await Resource.find(User, query);
// remove an item
await users[0].remove();
```

## Storage Drivers

SQLiteDriver:

```ts
// path to a file, or `:memory:` for in memory storage.
// if not provided, defaults to `process.env.SQLITE_DB_PATH`

const driver = new SQLiteDriver('path/to/file.db');
```

StoreDriver (for a [JSON store](https://github.com/cloud-cli/json-store)):

```ts
// address of Store API to use.
// if not provided, defaults to `process.env.STORE_URL`

const driver = new StoreDriver('https://store.io/hash');
```
2 changes: 1 addition & 1 deletion src/sqlite-driver.ts
Expand Up @@ -7,7 +7,7 @@ export class SQLiteDriver extends ResourceDriver {
readonly db: Database;

/* istanbul ignore next */
constructor(path = process.cwd() + '/cloud.db') {
constructor(path = process.env.SQLITE_DB_PATH) {
super();
this.db = new SQLite(path);
this.db.pragma('journal_mode = WAL');
Expand Down

0 comments on commit 4529912

Please sign in to comment.