File tree Expand file tree Collapse file tree 13 files changed +62
-37
lines changed Expand file tree Collapse file tree 13 files changed +62
-37
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,14 @@ const Model = require('objection').Model;
6
6
const User = require ( './user' ) ;
7
7
const AccessListAuth = require ( './access_list_auth' ) ;
8
8
const AccessListClient = require ( './access_list_client' ) ;
9
+ const now = require ( './now_helper' ) ;
9
10
10
11
Model . knex ( db ) ;
11
12
12
13
class AccessList extends Model {
13
14
$beforeInsert ( ) {
14
- this . created_on = Model . raw ( 'NOW()' ) ;
15
- this . modified_on = Model . raw ( 'NOW()' ) ;
15
+ this . created_on = now ( ) ;
16
+ this . modified_on = now ( ) ;
16
17
17
18
// Default for meta
18
19
if ( typeof this . meta === 'undefined' ) {
@@ -21,7 +22,7 @@ class AccessList extends Model {
21
22
}
22
23
23
24
$beforeUpdate ( ) {
24
- this . modified_on = Model . raw ( 'NOW()' ) ;
25
+ this . modified_on = now ( ) ;
25
26
}
26
27
27
28
static get name ( ) {
Original file line number Diff line number Diff line change 3
3
4
4
const db = require ( '../db' ) ;
5
5
const Model = require ( 'objection' ) . Model ;
6
+ const now = require ( './now_helper' ) ;
6
7
7
8
Model . knex ( db ) ;
8
9
9
10
class AccessListAuth extends Model {
10
11
$beforeInsert ( ) {
11
- this . created_on = Model . raw ( 'NOW()' ) ;
12
- this . modified_on = Model . raw ( 'NOW()' ) ;
12
+ this . created_on = now ( ) ;
13
+ this . modified_on = now ( ) ;
13
14
14
15
// Default for meta
15
16
if ( typeof this . meta === 'undefined' ) {
@@ -18,7 +19,7 @@ class AccessListAuth extends Model {
18
19
}
19
20
20
21
$beforeUpdate ( ) {
21
- this . modified_on = Model . raw ( 'NOW()' ) ;
22
+ this . modified_on = now ( ) ;
22
23
}
23
24
24
25
static get name ( ) {
Original file line number Diff line number Diff line change 3
3
4
4
const db = require ( '../db' ) ;
5
5
const Model = require ( 'objection' ) . Model ;
6
+ const now = require ( './now_helper' ) ;
6
7
7
8
Model . knex ( db ) ;
8
9
9
10
class AccessListClient extends Model {
10
11
$beforeInsert ( ) {
11
- this . created_on = Model . raw ( 'NOW()' ) ;
12
- this . modified_on = Model . raw ( 'NOW()' ) ;
12
+ this . created_on = now ( ) ;
13
+ this . modified_on = now ( ) ;
13
14
14
15
// Default for meta
15
16
if ( typeof this . meta === 'undefined' ) {
@@ -18,7 +19,7 @@ class AccessListClient extends Model {
18
19
}
19
20
20
21
$beforeUpdate ( ) {
21
- this . modified_on = Model . raw ( 'NOW()' ) ;
22
+ this . modified_on = now ( ) ;
22
23
}
23
24
24
25
static get name ( ) {
Original file line number Diff line number Diff line change 4
4
const db = require ( '../db' ) ;
5
5
const Model = require ( 'objection' ) . Model ;
6
6
const User = require ( './user' ) ;
7
+ const now = require ( './now_helper' ) ;
7
8
8
9
Model . knex ( db ) ;
9
10
10
11
class AuditLog extends Model {
11
12
$beforeInsert ( ) {
12
- this . created_on = Model . raw ( 'NOW()' ) ;
13
- this . modified_on = Model . raw ( 'NOW()' ) ;
13
+ this . created_on = now ( ) ;
14
+ this . modified_on = now ( ) ;
14
15
15
16
// Default for meta
16
17
if ( typeof this . meta === 'undefined' ) {
@@ -19,7 +20,7 @@ class AuditLog extends Model {
19
20
}
20
21
21
22
$beforeUpdate ( ) {
22
- this . modified_on = Model . raw ( 'NOW()' ) ;
23
+ this . modified_on = now ( ) ;
23
24
}
24
25
25
26
static get name ( ) {
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const bcrypt = require('bcrypt');
5
5
const db = require ( '../db' ) ;
6
6
const Model = require ( 'objection' ) . Model ;
7
7
const User = require ( './user' ) ;
8
+ const now = require ( './now_helper' ) ;
8
9
9
10
Model . knex ( db ) ;
10
11
@@ -24,8 +25,8 @@ function encryptPassword () {
24
25
25
26
class Auth extends Model {
26
27
$beforeInsert ( queryContext ) {
27
- this . created_on = Model . raw ( 'NOW()' ) ;
28
- this . modified_on = Model . raw ( 'NOW()' ) ;
28
+ this . created_on = now ( ) ;
29
+ this . modified_on = now ( ) ;
29
30
30
31
// Default for meta
31
32
if ( typeof this . meta === 'undefined' ) {
@@ -36,7 +37,7 @@ class Auth extends Model {
36
37
}
37
38
38
39
$beforeUpdate ( queryContext ) {
39
- this . modified_on = Model . raw ( 'NOW()' ) ;
40
+ this . modified_on = now ( ) ;
40
41
return encryptPassword . apply ( this , queryContext ) ;
41
42
}
42
43
Original file line number Diff line number Diff line change 4
4
const db = require ( '../db' ) ;
5
5
const Model = require ( 'objection' ) . Model ;
6
6
const User = require ( './user' ) ;
7
+ const now = require ( './now_helper' ) ;
7
8
8
9
Model . knex ( db ) ;
9
10
10
11
class Certificate extends Model {
11
12
$beforeInsert ( ) {
12
- this . created_on = Model . raw ( 'NOW()' ) ;
13
- this . modified_on = Model . raw ( 'NOW()' ) ;
13
+ this . created_on = now ( ) ;
14
+ this . modified_on = now ( ) ;
14
15
15
16
// Default for expires_on
16
17
if ( typeof this . expires_on === 'undefined' ) {
17
- this . expires_on = Model . raw ( 'NOW()' ) ;
18
+ this . expires_on = now ( ) ;
18
19
}
19
20
20
21
// Default for domain_names
@@ -31,7 +32,7 @@ class Certificate extends Model {
31
32
}
32
33
33
34
$beforeUpdate ( ) {
34
- this . modified_on = Model . raw ( 'NOW()' ) ;
35
+ this . modified_on = now ( ) ;
35
36
36
37
// Sort domain_names
37
38
if ( typeof this . domain_names !== 'undefined' ) {
Original file line number Diff line number Diff line change @@ -5,13 +5,14 @@ const db = require('../db');
5
5
const Model = require ( 'objection' ) . Model ;
6
6
const User = require ( './user' ) ;
7
7
const Certificate = require ( './certificate' ) ;
8
+ const now = require ( './now_helper' ) ;
8
9
9
10
Model . knex ( db ) ;
10
11
11
12
class DeadHost extends Model {
12
13
$beforeInsert ( ) {
13
- this . created_on = Model . raw ( 'NOW()' ) ;
14
- this . modified_on = Model . raw ( 'NOW()' ) ;
14
+ this . created_on = now ( ) ;
15
+ this . modified_on = now ( ) ;
15
16
16
17
// Default for domain_names
17
18
if ( typeof this . domain_names === 'undefined' ) {
@@ -27,7 +28,7 @@ class DeadHost extends Model {
27
28
}
28
29
29
30
$beforeUpdate ( ) {
30
- this . modified_on = Model . raw ( 'NOW()' ) ;
31
+ this . modified_on = now ( ) ;
31
32
32
33
// Sort domain_names
33
34
if ( typeof this . domain_names !== 'undefined' ) {
Original file line number Diff line number Diff line change
1
+ const db = require ( '../db' ) ;
2
+ const config = require ( 'config' ) ;
3
+ const Model = require ( 'objection' ) . Model ;
4
+
5
+ Model . knex ( db ) ;
6
+
7
+ module . exports = function ( ) {
8
+ if ( config . database . knex && config . database . knex . client === 'sqlite3' ) {
9
+ return Model . raw ( 'date(\'now\')' ) ;
10
+ } else {
11
+ return Model . raw ( 'NOW()' ) ;
12
+ }
13
+ } ;
Original file line number Diff line number Diff line change @@ -6,13 +6,14 @@ const Model = require('objection').Model;
6
6
const User = require ( './user' ) ;
7
7
const AccessList = require ( './access_list' ) ;
8
8
const Certificate = require ( './certificate' ) ;
9
+ const now = require ( './now_helper' ) ;
9
10
10
11
Model . knex ( db ) ;
11
12
12
13
class ProxyHost extends Model {
13
14
$beforeInsert ( ) {
14
- this . created_on = Model . raw ( 'NOW()' ) ;
15
- this . modified_on = Model . raw ( 'NOW()' ) ;
15
+ this . created_on = now ( ) ;
16
+ this . modified_on = now ( ) ;
16
17
17
18
// Default for domain_names
18
19
if ( typeof this . domain_names === 'undefined' ) {
@@ -28,7 +29,7 @@ class ProxyHost extends Model {
28
29
}
29
30
30
31
$beforeUpdate ( ) {
31
- this . modified_on = Model . raw ( 'NOW()' ) ;
32
+ this . modified_on = now ( ) ;
32
33
33
34
// Sort domain_names
34
35
if ( typeof this . domain_names !== 'undefined' ) {
Original file line number Diff line number Diff line change @@ -5,13 +5,14 @@ const db = require('../db');
5
5
const Model = require ( 'objection' ) . Model ;
6
6
const User = require ( './user' ) ;
7
7
const Certificate = require ( './certificate' ) ;
8
+ const now = require ( './now_helper' ) ;
8
9
9
10
Model . knex ( db ) ;
10
11
11
12
class RedirectionHost extends Model {
12
13
$beforeInsert ( ) {
13
- this . created_on = Model . raw ( 'NOW()' ) ;
14
- this . modified_on = Model . raw ( 'NOW()' ) ;
14
+ this . created_on = now ( ) ;
15
+ this . modified_on = now ( ) ;
15
16
16
17
// Default for domain_names
17
18
if ( typeof this . domain_names === 'undefined' ) {
@@ -27,7 +28,7 @@ class RedirectionHost extends Model {
27
28
}
28
29
29
30
$beforeUpdate ( ) {
30
- this . modified_on = Model . raw ( 'NOW()' ) ;
31
+ this . modified_on = now ( ) ;
31
32
32
33
// Sort domain_names
33
34
if ( typeof this . domain_names !== 'undefined' ) {
You can’t perform that action at this time.
0 commit comments