Skip to content

Commit 65df434

Browse files
authored
Develop (#8)
* database session adapter container naming fixes * table payload column * session migration stub fixes
1 parent f7229c5 commit 65df434

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

adapter/database.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ class Database {
1010
}
1111

1212
read(sid, cb) {
13-
this[kConnection].table(this[kTable]).where({ sid }).value('data').then(res => {
13+
this[kConnection].table(this[kTable]).where({ sid }).value('payload').then(res => {
1414
cb(null, (res ? JSON.parse(res) : {}))
1515
}).catch(err => {
1616
cb(err, null)
1717
})
1818
}
1919

2020
write(sid, data, cb) {
21-
this[kConnection].table(this[kTable]).updateOrInsert({ sid }, { data: JSON.stringify(data) }).then(res => {
21+
this[kConnection].table(this[kTable]).updateOrInsert({ sid }, { payload: JSON.stringify(data) }).then(res => {
2222
cb(null, res)
2323
}).catch(function(err) {
2424
cb(err, null)
@@ -34,4 +34,4 @@ class Database {
3434
}
3535

3636
}
37-
module.exports = Database
37+
module.exports = Database

console/stubs/database.stub

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
const Schema = require('@ostro/database/schema')
1+
const Schema = require("@ostro/support/facades/schema");
22
const Migration = require('@ostro/database/migration')
33

44
class CreateSessionsTable extends Migration {
55

66
async up() {
77
await Schema.create('sessions', function ($table) {
8-
$table.string('id').primary();
9-
$table.foreignId('user_id').nullable().index();
8+
$table.string('sid').primary();
109
$table.string('ip_address', 45).nullable();
1110
$table.text('user_agent').nullable();
12-
$table.text('payload');
11+
$table.text('payload').nullable();
1312
$table.integer('last_activity').index();
1413
});
1514
}
@@ -19,4 +18,4 @@ class CreateSessionsTable extends Migration {
1918
}
2019
}
2120

22-
module.exports = CreateSessionsTable
21+
module.exports = CreateSessionsTable

0 commit comments

Comments
 (0)