@@ -20,15 +20,15 @@ import {Datastore} from '.';
2020import { Entity } from './entity' ;
2121import { Transaction } from './transaction' ;
2222
23- export type Operator = '=' | '<' | '>' | '<=' | '>=' | 'HAS_ANCESTOR' ;
23+ export type Operator = '=' | '<' | '>' | '<=' | '>=' | 'HAS_ANCESTOR' ;
2424
2525export interface OrderOptions {
2626 descending ?: boolean ;
2727}
2828
2929export interface Order {
3030 name : string ;
31- sign : '-' | '+' ;
31+ sign : '-' | '+' ;
3232}
3333
3434export interface Filter {
@@ -58,24 +58,29 @@ export interface Filter {
5858 * const query = datastore.createQuery('AnimalNamespace', 'Lion');
5959 */
6060class Query {
61- scope ?: Datastore | Transaction ;
62- namespace ?: string | null ;
61+ scope ?: Datastore | Transaction ;
62+ namespace ?: string | null ;
6363 kinds : string [ ] ;
6464 filters : Filter [ ] ;
6565 orders : Order [ ] ;
6666 groupByVal : Array < { } > ;
6767 selectVal : Array < { } > ;
68- startVal : string | Buffer | null ;
69- endVal : string | Buffer | null ;
68+ startVal : string | Buffer | null ;
69+ endVal : string | Buffer | null ;
7070 limitVal : number ;
7171 offsetVal : number ;
7272
73- constructor ( scope ?: Datastore | Transaction , kinds ?: string [ ] | null ) ;
73+ constructor ( scope ?: Datastore | Transaction , kinds ?: string [ ] | null ) ;
7474 constructor (
75- scope ?: Datastore | Transaction , namespace ?: string | null , kinds ?: string [ ] ) ;
75+ scope ?: Datastore | Transaction ,
76+ namespace ?: string | null ,
77+ kinds ?: string [ ]
78+ ) ;
7679 constructor (
77- scope ?: Datastore | Transaction , namespaceOrKinds ?: string | string [ ] | null ,
78- kinds ?: string [ ] ) {
80+ scope ?: Datastore | Transaction ,
81+ namespaceOrKinds ?: string | string [ ] | null ,
82+ kinds ?: string [ ]
83+ ) {
7984 let namespace = namespaceOrKinds as string | null ;
8085 if ( ! kinds ) {
8186 kinds = namespaceOrKinds as string [ ] ;
@@ -260,7 +265,7 @@ class Query {
260265 * const companyQuery = datastore.createQuery('Company');
261266 * const groupedQuery = companyQuery.groupBy(['name', 'size']);
262267 */
263- groupBy ( fieldNames : string | string [ ] ) {
268+ groupBy ( fieldNames : string | string [ ] ) {
264269 this . groupByVal = arrify ( fieldNames ) ;
265270 return this ;
266271 }
@@ -287,7 +292,7 @@ class Query {
287292 * // Only retrieve the name and size properties.
288293 * const selectQuery = companyQuery.select(['name', 'size']);
289294 */
290- select ( fieldNames : string | string [ ] ) {
295+ select ( fieldNames : string | string [ ] ) {
291296 this . selectVal = arrify ( fieldNames ) ;
292297 return this ;
293298 }
@@ -310,7 +315,7 @@ class Query {
310315 * // Retrieve results starting from cursorToken.
311316 * const startQuery = companyQuery.start(cursorToken);
312317 */
313- start ( start : string | Buffer ) {
318+ start ( start : string | Buffer ) {
314319 this . startVal = start ;
315320 return this ;
316321 }
@@ -333,7 +338,7 @@ class Query {
333338 * // Retrieve results limited to the extent of cursorToken.
334339 * const endQuery = companyQuery.end(cursorToken);
335340 */
336- end ( end : string | Buffer ) {
341+ end ( end : string | Buffer ) {
337342 this . endVal = end ;
338343 return this ;
339344 }
@@ -438,13 +443,15 @@ class Query {
438443 * const entities = data[0];
439444 * });
440445 */
441- run ( optionsOrCallback ?: RunQueryOptions | RunQueryCallback ,
442- cb ?: RunQueryCallback ) : void | Promise < RunQueryResponse > {
446+ run (
447+ optionsOrCallback ?: RunQueryOptions | RunQueryCallback ,
448+ cb ?: RunQueryCallback
449+ ) : void | Promise < RunQueryResponse > {
443450 const query = this as Query ;
444451 const options =
445- typeof optionsOrCallback === 'object' ? optionsOrCallback : { } ;
452+ typeof optionsOrCallback === 'object' ? optionsOrCallback : { } ;
446453 const callback =
447- typeof optionsOrCallback === 'function' ? optionsOrCallback : cb ! ;
454+ typeof optionsOrCallback === 'function' ? optionsOrCallback : cb ! ;
448455 const runQuery = this . scope ! . runQuery . bind ( this . scope ) ;
449456 return ( runQuery as Function ) ( query , options , callback ) ;
450457 }
@@ -491,12 +498,12 @@ class Query {
491498}
492499
493500export interface QueryProto {
494- startCursor ?: string | Buffer ;
501+ startCursor ?: string | Buffer ;
495502 distinctOn : { } ;
496503 kind : { } ;
497504 order : { } ;
498505 projection : { } ;
499- endCursor ?: string | Buffer ;
506+ endCursor ?: string | Buffer ;
500507 limit ?: { } ;
501508 offset ?: number ;
502509 filter ?: { } ;
@@ -510,17 +517,19 @@ export interface QueryProto {
510517export { Query } ;
511518
512519export interface RunQueryOptions {
513- consistency ?: 'strong' | 'eventual' ;
520+ consistency ?: 'strong' | 'eventual' ;
514521}
515522
516523export interface RunQueryCallback {
517- ( err : Error | null , entities ?: Entity [ ] , info ?: RunQueryInfo ) : void ;
524+ ( err : Error | null , entities ?: Entity [ ] , info ?: RunQueryInfo ) : void ;
518525}
519526
520527export type RunQueryResponse = [ Entity [ ] , RunQueryInfo ] ;
521528
522529export interface RunQueryInfo {
523530 endCursor ?: string ;
524- moreResults ?: 'MORE_RESULTS_AFTER_LIMIT' | 'MORE_RESULTS_AFTER_CURSOR' |
525- 'NO_MORE_RESULTS' ;
531+ moreResults ?:
532+ | 'MORE_RESULTS_AFTER_LIMIT'
533+ | 'MORE_RESULTS_AFTER_CURSOR'
534+ | 'NO_MORE_RESULTS' ;
526535}
0 commit comments