greenlock-store-sequelize.js/README.md

72 lines
1.6 KiB
Markdown
Raw Normal View History

2019-04-20 22:02:45 +00:00
# [greenlock-store-sequelize](https://git.rootprojects.org/root/greenlock-store-sequelize.js) | A [Root](https://rootprojects.org) project
> A database-driven Greenlock storage plugin with wildcard support.
## Usage
To use, provide this Greenlock storage plugin as the `store` attribute when you
invoke `create`.
```js
2019-04-20 22:02:45 +00:00
greenlock.create({
store: require('le-store-sequelize')
});
```
2019-04-10 14:17:15 +00:00
## Configuration
2019-04-10 14:17:15 +00:00
### Defaults
No configuration is required. By default, you'll get a baked-in Sequelize
2019-04-20 22:02:45 +00:00
database running [sqlite3](https://www.npmjs.com/package/sqlite3).
2019-04-10 14:17:15 +00:00
### Database Connection
2019-04-10 14:11:38 +00:00
Without `config.dbOptions`, the baked-in sequelize object uses sqlite3 with
2019-04-20 22:02:45 +00:00
defaults. If `config.dbOptions` is provided, you can configure the database
connection per the Sequelize documentation.
2019-04-10 14:11:38 +00:00
2019-04-20 22:02:45 +00:00
If a dialect other than sqlite3 is used, dependencies will need to be
installed.
2019-04-10 14:11:38 +00:00
2019-04-20 22:02:45 +00:00
```javascript
2019-04-10 14:11:38 +00:00
greenlock.create({
2019-04-20 22:02:45 +00:00
store: require('le-store-sequelize')({
dbConfig: {
username: 'mysqluser',
password: 'mysqlpassword',
database: 'mysqldatabase,
host: '127.0.0.1',
dialect: 'mysql'
}
})
2019-04-10 14:11:38 +00:00
});
```
The database can also be configured using an env variable.
```javascript
2019-04-20 22:02:45 +00:00
greenlock.create({
store: require('greenlock-store-sequelize')({
dbConfig: {
use_env_variable: 'DB_URL'
}
})
2019-04-10 14:11:38 +00:00
});
```
2019-04-10 14:17:15 +00:00
### Custom Database Object
2019-04-10 14:20:34 +00:00
If you already have a Sequelize object, you can pass that in as `config.db`,
circumventing the baked-in database entirely.
2019-04-10 14:17:15 +00:00
```javascript
2019-04-20 22:02:45 +00:00
var db = require('./db'); // your db
2019-04-10 14:17:15 +00:00
greenlock.create({
2019-04-20 22:02:45 +00:00
store: require('le-store-sequelize')({
db
})
2019-04-10 14:17:15 +00:00
});
```