express-session-rethinkdb-esm 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/rdb-session.js +6 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-session-rethinkdb-esm",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "license": "MIT",
5
5
  "author": "Robert Sirois",
6
6
  "homepage": "https://github.com/rpsirois/express-session-rethinkdb-esm#readme",
package/rdb-session.js CHANGED
@@ -10,7 +10,9 @@ export default cfg => (
10
10
  Object.assign(this, defaults, opt)
11
11
  if (! this.client) throw new Error('RethinkdbSessionStore requires a client in setup options.')
12
12
  if (! this.conn) throw new Error('RethinkdbSessionStore requires a connection in setup options.')
13
- this.initDb(this.client, this.conn)
13
+ let _p_then
14
+ this.ready = new Promise( then => _p_then = then )
15
+ this.initDb( this.client, this.conn, _p_then )
14
16
  }
15
17
 
16
18
  getExpiry( cookie ) {
@@ -19,13 +21,15 @@ export default cfg => (
19
21
  : new Date(Date.now() + this.ttl)
20
22
  }
21
23
 
22
- async initDb( r, rc ) {
24
+ async initDb( r, rc, then ) {
23
25
  let { table } = this
24
26
  let existing_tables = await r.tableList().run(rc)
25
27
 
26
28
  if (existing_tables.indexOf( table ) < 0)
27
29
  await r.tableCreate( table ).run(rc)
28
30
  this._t = r.table(table)
31
+ then( this._t )
32
+ return this._t
29
33
  }
30
34
 
31
35
  async all( cb ) {