@@ -13,6 +13,9 @@ import deepcopy from 'deepcopy';
13
13
import logger from '../logger' ;
14
14
import * as SchemaController from './SchemaController' ;
15
15
import { StorageAdapter } from '../Adapters/Storage/StorageAdapter' ;
16
+ import type { QueryOptions ,
17
+ FullQueryOptions } from '../Adapters/Storage/StorageAdapter' ;
18
+
16
19
function addWriteACL ( query , acl ) {
17
20
const newQuery = _ . cloneDeep ( query ) ;
18
21
//Can't be any existing '_wperm' query, we don't allow client queries on that, no need to $and
@@ -152,13 +155,7 @@ const filterSensitiveData = (isMaster, aclGroup, className, object) => {
152
155
return object ;
153
156
} ;
154
157
155
- type Options = {
156
- acl ?: string [ ]
157
- }
158
-
159
- type LoadSchemaOptions = {
160
- clearCache : boolean
161
- }
158
+ import type { LoadSchemaOptions } from './types' ;
162
159
163
160
// Runs an update on the database.
164
161
// Returns a promise for an object with the new values for field
@@ -349,7 +346,7 @@ class DatabaseController {
349
346
// Returns a promise that resolves to the new schema.
350
347
// This does not update this.schema, because in a situation like a
351
348
// batch request, that could confuse other users of the schema.
352
- validateObject ( className : string , object : any , query : any , { acl } : Options ) : Promise < boolean > {
349
+ validateObject ( className : string , object : any , query : any , { acl } : QueryOptions ) : Promise < boolean > {
353
350
let schema ;
354
351
const isMaster = acl === undefined ;
355
352
var aclGroup : string [ ] = acl || [ ] ;
@@ -368,7 +365,7 @@ class DatabaseController {
368
365
acl,
369
366
many,
370
367
upsert,
371
- } : any = { } , skipSanitization : boolean = false ) : Promise < any > {
368
+ } : FullQueryOptions = { } , skipSanitization : boolean = false ) : Promise < any > {
372
369
const originalQuery = query ;
373
370
const originalUpdate = update ;
374
371
// Make a copy of the object, so we don't mutate the incoming data.
@@ -544,7 +541,7 @@ class DatabaseController {
544
541
// acl: a list of strings. If the object to be updated has an ACL,
545
542
// one of the provided strings must provide the caller with
546
543
// write permissions.
547
- destroy ( className : string , query : any , { acl } : Options = { } ) : Promise < any > {
544
+ destroy ( className : string , query : any , { acl } : QueryOptions = { } ) : Promise < any > {
548
545
const isMaster = acl === undefined ;
549
546
const aclGroup = acl || [ ] ;
550
547
@@ -586,7 +583,7 @@ class DatabaseController {
586
583
587
584
// Inserts an object into the database.
588
585
// Returns a promise that resolves successfully iff the object saved.
589
- create ( className : string , object : any , { acl } : Options = { } ) : Promise < any > {
586
+ create ( className : string , object : any , { acl } : QueryOptions = { } ) : Promise < any > {
590
587
// Make a copy of the object, so we don't mutate the incoming data.
591
588
const originalObject = object ;
592
589
object = transformObjectACL ( object ) ;
@@ -646,7 +643,7 @@ class DatabaseController {
646
643
647
644
// Returns a promise for a list of related ids given an owning id.
648
645
// className here is the owning className.
649
- relatedIds ( className : string , key : string , owningId : string , queryOptions : any ) : Promise < Array < string >> {
646
+ relatedIds ( className : string , key : string , owningId : string , queryOptions : QueryOptions ) : Promise < Array < string >> {
650
647
const { skip, limit, sort } = queryOptions ;
651
648
const findOptions = { } ;
652
649
if ( sort && sort . createdAt && this . adapter . canSortOnJoinTables ) {
0 commit comments