Last active
September 15, 2020 17:04
-
-
Save kallefrombosnia/ba7181ed1a0f9348ad610404aa64c5d5 to your computer and use it in GitHub Desktop.
Example of setting lowdb with default values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lowdb from 'lowdb'; | |
import FileSync from 'lowdb/adapters/FileSync'; | |
interface Teams { | |
team_name: string; | |
team_short_name: string; | |
team_logo_name: string; | |
team_description: string; | |
} | |
interface DatabaseType { | |
teams: Array<Teams>; | |
} | |
const adapter = new FileSync<DatabaseType>(__dirname + '/db.json', { | |
defaultValue: { | |
teams: [] | |
} | |
}); | |
const db = lowdb(adapter); | |
export default db; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment