@@ -4,6 +4,9 @@ import { IndexPriority, IndexLockMode, FieldIndexing, FieldStorage, FieldTermVec
44import { IDocumentStore } from "../IDocumentStore" ;
55import { PutIndexesOperation } from "../Operations/Indexes/PutIndexesOperation" ;
66import { SpatialOptions } from "./Spatial" ;
7+ import { ErrorFirstCallback } from "../../Types/Callbacks" ;
8+ import { TypeUtil } from "../../Utility/TypeUtil" ;
9+ import { passResultToCallback } from "../../Utility/PromiseUtil" ;
710
811export abstract class AbstractIndexCreationTaskBase {
912
@@ -39,25 +42,66 @@ export abstract class AbstractIndexCreationTaskBase {
3942 /**
4043 * Executes the index creation against the specified document store.
4144 */
42- public async execute (
43- store : IDocumentStore ) : Promise < void > ;
45+ public async execute ( store : IDocumentStore ) : Promise < void > ;
46+ /**
47+ * Executes the index creation against the specified document store.
48+ */
49+ public async execute ( store : IDocumentStore , callback : ErrorFirstCallback < void > ) : Promise < void > ;
50+ /**
51+ * Executes the index creation against the specified document store.
52+ */
53+ public async execute ( store : IDocumentStore , conventions : DocumentConventions ) : Promise < void > ;
4454 /**
4555 * Executes the index creation against the specified document store.
4656 */
4757 public async execute (
48- store : IDocumentStore , conventions : DocumentConventions ) : Promise < void > ;
58+ store : IDocumentStore ,
59+ conventions : DocumentConventions ,
60+ callback : ErrorFirstCallback < void > ) : Promise < void > ;
61+ /**
62+ * Executes the index creation against the specified document store.
63+ */
64+ public async execute ( store : IDocumentStore , conventions : DocumentConventions , database : string ) : Promise < void > ;
4965 /**
5066 * Executes the index creation against the specified document store.
5167 */
5268 public async execute (
53- store : IDocumentStore , conventions : DocumentConventions , database : string ) : Promise < void > ;
69+ store : IDocumentStore ,
70+ conventions : DocumentConventions ,
71+ database : string ,
72+ callback : ErrorFirstCallback < void > ) : Promise < void > ;
5473 public async execute (
55- store : IDocumentStore , conventions ?: DocumentConventions , database ?: string ) : Promise < void > {
56- if ( arguments . length === 1 ) {
57- return store . executeIndex ( this ) ;
74+ store : IDocumentStore ,
75+ conventionsOrCallback ?: DocumentConventions | ErrorFirstCallback < void > ,
76+ databaseOrCallback ?: string | ErrorFirstCallback < void > ,
77+ callback ?: ErrorFirstCallback < void > ) : Promise < void > {
78+
79+ let conventions : DocumentConventions ;
80+ let database : string ;
81+ if ( arguments . length > 1 ) {
82+ if ( TypeUtil . isFunction ( conventionsOrCallback ) ) {
83+ callback = conventionsOrCallback ;
84+ } else if ( TypeUtil . isFunction ( databaseOrCallback ) ) {
85+ callback = databaseOrCallback ;
86+ conventions = conventionsOrCallback ;
87+ } else {
88+ conventions = conventionsOrCallback ;
89+ database = databaseOrCallback ;
90+ }
91+ }
92+
93+ callback = callback || TypeUtil . NOOP ;
94+
95+ let resultPromise ;
96+ if ( ! conventions && ! database ) {
97+ resultPromise = store . executeIndex ( this ) ;
5898 } else {
59- return this . _putIndex ( store , conventions , database ) ;
99+ resultPromise = this . _putIndex ( store , conventions , database ) ;
60100 }
101+
102+ passResultToCallback ( resultPromise , callback ) ;
103+
104+ return resultPromise ;
61105 }
62106
63107 private async _putIndex (
0 commit comments