@@ -300,12 +300,94 @@ export declare class DataSource extends EventEmitter {
300300 ping ( callback : Callback ) : void ;
301301
302302 // Only promise variant, callback is intentionally not supported.
303+
304+ /**
305+ * Execute a SQL command.
306+ *
307+ * **WARNING:** In general, it is always better to perform database actions
308+ * through repository methods. Directly executing SQL may lead to unexpected
309+ * results, corrupted data, security vulnerabilities and other issues.
310+ *
311+ * @example
312+ *
313+ * ```ts
314+ * // MySQL
315+ * const result = await db.execute(
316+ * 'SELECT * FROM Products WHERE size > ?',
317+ * [42]
318+ * );
319+ *
320+ * // PostgreSQL
321+ * const result = await db.execute(
322+ * 'SELECT * FROM Products WHERE size > $1',
323+ * [42]
324+ * );
325+ * ```
326+ *
327+ * @param command A parameterized SQL command or query.
328+ * Check your database documentation for information on which characters to
329+ * use as parameter placeholders.
330+ * @param parameters List of parameter values to use.
331+ * @param options Additional options, for example `transaction`.
332+ * @returns A promise which resolves to the command output as returned by the
333+ * database driver. The output type (data structure) is database specific and
334+ * often depends on the command executed.
335+ */
303336 execute (
304337 command : string | object ,
305- args ?: any [ ] | object ,
338+ parameters ?: any [ ] | object ,
306339 options ?: Options ,
307340 ) : Promise < any > ;
308341
342+ /**
343+ * Execute a MongoDB command.
344+ *
345+ * **WARNING:** In general, it is always better to perform database actions
346+ * through repository methods. Directly executing MongoDB commands may lead
347+ * to unexpected results and other issues.
348+ *
349+ * @example
350+ *
351+ * ```ts
352+ * const result = await db.execute('MyCollection', 'aggregate', [
353+ * {$lookup: {
354+ * // ...
355+ * }},
356+ * {$unwind: '$data'},
357+ * {$out: 'tempData'}
358+ * ]);
359+ * ```
360+ *
361+ * @param collectionName The name of the collection to execute the command on.
362+ * @param command The command name. See
363+ * [Collection API docs](http://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html)
364+ * for the list of commands supported by the MongoDB client.
365+ * @param parameters Command parameters (arguments), as described in MongoDB API
366+ * docs for individual collection methods.
367+ * @returns A promise which resolves to the command output as returned by the
368+ * database driver.
369+ */
370+ execute (
371+ collectionName : string ,
372+ command : string ,
373+ ...parameters : any [ ] ,
374+ ) : Promise < any > ;
375+
376+ /**
377+ * Execute a raw database command using a connector that's not described
378+ * by LoopBack's `execute` API yet.
379+ *
380+ * **WARNING:** In general, it is always better to perform database actions
381+ * through repository methods. Directly executing database commands may lead
382+ * to unexpected results and other issues.
383+ *
384+ * @param args Command and parameters, please consult your connector's
385+ * documentation to learn about supported commands and their parameters.
386+ * @returns A promise which resolves to the command output as returned by the
387+ * database driver.
388+ */
389+ execute ( ...args : any [ ] ) : Promise < any > ;
390+
309391 /**
310392 * Begin a new transaction.
311393 *
0 commit comments