@@ -20,7 +20,7 @@ import {
20
20
RecordIdentity ,
21
21
AttributeFilterSpecifier ,
22
22
Schema ,
23
- QueryExpression
23
+ QueryExpression ,
24
24
} from '@orbit/data' ;
25
25
import Knex , { Config } from 'knex' ;
26
26
import { QueryBuilder , ModelClass , transaction , Transaction } from 'objection' ;
@@ -70,7 +70,7 @@ export class Processor {
70
70
}
71
71
72
72
async patch ( operations : RecordOperation [ ] ) {
73
- return transaction ( this . _db as Knex , async trx => {
73
+ return transaction ( this . _db as Knex , async ( trx ) => {
74
74
const result : OrbitRecord [ ] = [ ] ;
75
75
for ( let operation of operations ) {
76
76
result . push ( await this . processOperation ( operation , trx ) ) ;
@@ -80,7 +80,7 @@ export class Processor {
80
80
}
81
81
82
82
async query ( query : Query ) {
83
- return transaction ( this . _db as Knex , async trx => {
83
+ return transaction ( this . _db as Knex , async ( trx ) => {
84
84
return this . processQueryExpression ( query . expression , trx ) ;
85
85
} ) ;
86
86
}
@@ -133,21 +133,21 @@ export class Processor {
133
133
const model = await qb . upsertGraph ( data , {
134
134
insertMissing : true ,
135
135
relate : true ,
136
- unrelate : true
136
+ unrelate : true ,
137
137
} ) ;
138
138
139
139
return model . toOrbitRecord ( ) ;
140
140
}
141
141
142
142
protected async updateRecord ( op : UpdateRecordOperation , trx : Transaction ) {
143
143
const qb = this . queryForType ( trx , op . record . type ) . mergeContext ( {
144
- recordId : op . record . id
144
+ recordId : op . record . id ,
145
145
} ) ;
146
146
const data = this . parseOrbitRecord ( op . record ) ;
147
147
148
148
const model = await qb . upsertGraph ( data , {
149
149
relate : true ,
150
- unrelate : true
150
+ unrelate : true ,
151
151
} ) ;
152
152
153
153
return model . toOrbitRecord ( ) ;
@@ -156,7 +156,7 @@ export class Processor {
156
156
protected async removeRecord ( op : RemoveRecordOperation , trx : Transaction ) {
157
157
const { type, id } = op . record ;
158
158
const qb = this . queryForType ( trx , type ) . mergeContext ( {
159
- recordId : id
159
+ recordId : id ,
160
160
} ) ;
161
161
162
162
const model = ( await qb . findById ( id ) ) as BaseModel ;
@@ -171,11 +171,11 @@ export class Processor {
171
171
) {
172
172
const { type, id } = op . record ;
173
173
const qb = this . queryForType ( trx , type ) . mergeContext ( {
174
- recordId : id
174
+ recordId : id ,
175
175
} ) ;
176
176
177
177
const model = await qb . patchAndFetchById ( id , {
178
- [ op . attribute ] : op . value
178
+ [ op . attribute ] : op . value ,
179
179
} ) ;
180
180
181
181
return model . toOrbitRecord ( ) ;
@@ -187,7 +187,7 @@ export class Processor {
187
187
) {
188
188
const { type, id } = op . record ;
189
189
const qb = this . queryForType ( trx , type ) . mergeContext ( {
190
- recordId : id
190
+ recordId : id ,
191
191
} ) ;
192
192
const relatedId = op . relatedRecord ? op . relatedRecord . id : null ;
193
193
@@ -207,19 +207,19 @@ export class Processor {
207
207
) {
208
208
const { type, id } = op . record ;
209
209
const qb = this . queryForType ( trx , type ) . mergeContext ( {
210
- recordId : id
210
+ recordId : id ,
211
211
} ) ;
212
212
const relatedIds = op . relatedRecords . map ( ( { id } ) => id ) ;
213
213
214
214
const model = await qb . upsertGraph (
215
215
{
216
216
id,
217
- [ op . relationship ] : relatedIds . map ( id => ( { id } ) )
217
+ [ op . relationship ] : relatedIds . map ( ( id ) => ( { id } ) ) ,
218
218
} ,
219
219
{
220
220
insertMissing : false ,
221
221
relate : false ,
222
- unrelate : true
222
+ unrelate : true ,
223
223
}
224
224
) ;
225
225
@@ -232,7 +232,7 @@ export class Processor {
232
232
) {
233
233
const { type, id } = op . record ;
234
234
const qb = this . queryForType ( trx , type ) . mergeContext ( {
235
- recordId : id
235
+ recordId : id ,
236
236
} ) ;
237
237
const relatedId = op . relatedRecord . id ;
238
238
@@ -248,7 +248,7 @@ export class Processor {
248
248
) {
249
249
const { type, id } = op . record ;
250
250
const qb = this . queryForType ( trx , type ) . mergeContext ( {
251
- recordId : id
251
+ recordId : id ,
252
252
} ) ;
253
253
254
254
const model = ( await qb . findById ( id ) ) as BaseModel ;
@@ -264,7 +264,7 @@ export class Processor {
264
264
protected async findRecord ( expression : FindRecord , trx : Transaction ) {
265
265
const { id, type } = expression . record ;
266
266
const qb = this . queryForType ( trx , type ) . mergeContext ( {
267
- recordId : id
267
+ recordId : id ,
268
268
} ) ;
269
269
270
270
const model = ( await qb . findById ( id ) ) as BaseModel ;
@@ -280,7 +280,7 @@ export class Processor {
280
280
qb ,
281
281
expression
282
282
) ) as BaseModel [ ] ;
283
- return models . map ( model => model . toOrbitRecord ( ) ) ;
283
+ return models . map ( ( model ) => model . toOrbitRecord ( ) ) ;
284
284
} else if ( records ) {
285
285
const recordsByType = groupRecordsByType ( records ) ;
286
286
const recordsById : Record < string , OrbitRecord > = { } ;
@@ -292,7 +292,9 @@ export class Processor {
292
292
recordsById [ record . id ] = record . toOrbitRecord ( ) ;
293
293
}
294
294
}
295
- return records . map ( ( { id } ) => recordsById [ id ] ) . filter ( record => record ) ;
295
+ return records
296
+ . map ( ( { id } ) => recordsById [ id ] )
297
+ . filter ( ( record ) => record ) ;
296
298
}
297
299
throw new QueryExpressionParseError (
298
300
`FindRecords with no type or records is not recognized for SQLSource.` ,
@@ -306,11 +308,11 @@ export class Processor {
306
308
) {
307
309
const {
308
310
record : { id, type } ,
309
- relationship
311
+ relationship,
310
312
} = expression ;
311
313
312
314
let qb = this . queryForType ( trx , type ) . mergeContext ( {
313
- recordId : id
315
+ recordId : id ,
314
316
} ) ;
315
317
const parent = ( await qb . findById ( id ) ) as BaseModel ;
316
318
qb = this . queryForRelationship ( trx , parent , relationship ) ;
@@ -325,19 +327,19 @@ export class Processor {
325
327
) {
326
328
const {
327
329
record : { id, type } ,
328
- relationship
330
+ relationship,
329
331
} = expression ;
330
332
331
333
let qb = this . queryForType ( trx , type ) . mergeContext ( {
332
- recordId : id
334
+ recordId : id ,
333
335
} ) ;
334
336
const parent = ( await qb . findById ( id ) ) as BaseModel ;
335
337
const models = ( await this . parseQueryExpression (
336
338
this . queryForRelationship ( trx , parent , relationship ) ,
337
339
expression
338
340
) ) as BaseModel [ ] ;
339
341
340
- return models . map ( model => model . toOrbitRecord ( ) ) ;
342
+ return models . map ( ( model ) => model . toOrbitRecord ( ) ) ;
341
343
}
342
344
343
345
modelForType ( type : string ) : ModelClass < BaseModel > {
@@ -487,7 +489,7 @@ export class Processor {
487
489
}
488
490
489
491
if ( record . attributes ) {
490
- this . schema . eachAttribute ( record . type , property => {
492
+ this . schema . eachAttribute ( record . type , ( property ) => {
491
493
if ( record . attributes && record . attributes [ property ] !== undefined ) {
492
494
properties [ property ] = record . attributes [ property ] ;
493
495
}
@@ -517,7 +519,7 @@ export class Processor {
517
519
const tableName = tableize ( type ) ;
518
520
const fields : string [ ] = [ `${ tableName } .id` ] ;
519
521
520
- this . schema . eachAttribute ( type , property => {
522
+ this . schema . eachAttribute ( type , ( property ) => {
521
523
fields . push ( `${ tableName } .${ underscore ( property ) } ` ) ;
522
524
} ) ;
523
525
0 commit comments