Skip to content

Commit 314d1b5

Browse files
authored
Merge pull request #5 from mxstbr/db-path-option
Add ability to change db path from CLI
2 parents 5563753 + 4703a1d commit 314d1b5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ If you want to get all views for all ids, set the `all` query parameter to `true
6060

6161
`flat-file-db` is a fast in-process flat file database that caches all data in memory and persists it to an open file using an append-only algorithm ensuring compact file sizes and strong consistency. By using the filesystem for storage setup is easy and backups are only a copy & paste away. (in case you need more advanced features of a real database, swapping out `flat-file-db` for a real db shouldn't take long)
6262

63+
*If you want to change the path the database file is saved as pass it as an env variable called `DB_PATH`. E.g. `DB_PATH=storage/analytics.db micro-analytics`.*
64+
6365
## License
6466

6567
Copyright ©️ 2017 Maximilian Stoiber, licensed under the MIT License. See [`license.md`](./license.md) for more information.

src/db.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const flatfile = require('flat-file-db')
22
const promise = require('promise')
33

4-
const db = flatfile.sync('views.db')
4+
const db = flatfile.sync(process.env.DB_NAME || 'views.db')
55

66
const promisifiedDb = {
77
// Promisify async operations

0 commit comments

Comments
 (0)