mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
documentdb: Add typings for user-defined functions
This commit is contained in:
@@ -55,6 +55,31 @@ docDBClient.createStoredProcedure('collection', procedure, undefined, (error, re
|
||||
}
|
||||
});
|
||||
|
||||
var userDefinedFunction: docDB.UserDefinedFunction = {
|
||||
id: 'udf1',
|
||||
body: function () {
|
||||
console.log('foo');
|
||||
}
|
||||
};
|
||||
|
||||
docDBClient.createUserDefinedFunction('collection', userDefinedFunction, undefined, (error, result) => {
|
||||
if (error) {
|
||||
throw new Error(error.body);
|
||||
}
|
||||
else {
|
||||
console.log('Created function: ' + result.id);
|
||||
}
|
||||
});
|
||||
|
||||
docDBClient.queryUserDefinedFunctions('collection', "SELECT * FROM root", undefined).toArray((error, results) => {
|
||||
if (error) {
|
||||
throw new Error(error.body);
|
||||
}
|
||||
else {
|
||||
console.log('Number of functions in collection: ' + results.length);
|
||||
}
|
||||
});
|
||||
|
||||
var trigger: docDB.Trigger = {
|
||||
id: 'trigger-one',
|
||||
body: function () {
|
||||
|
||||
33
documentdb/index.d.ts
vendored
33
documentdb/index.d.ts
vendored
@@ -154,6 +154,10 @@ interface ProcedureMeta extends AbstractMeta {
|
||||
body: string;
|
||||
}
|
||||
|
||||
/** Represents the meta data for a user-defined function. */
|
||||
interface UserDefinedFunctionMeta extends AbstractMeta {
|
||||
}
|
||||
|
||||
/** Represents the meta data for a trigger. */
|
||||
interface TriggerMeta extends AbstractMeta {
|
||||
body: string;
|
||||
@@ -181,6 +185,13 @@ export interface Procedure extends UniqueId {
|
||||
body(...params: any[]): void;
|
||||
}
|
||||
|
||||
/** Represents a DocumentDB user-defined function. */
|
||||
export interface UserDefinedFunction extends UniqueId {
|
||||
|
||||
/** The function representing the user-defined function. */
|
||||
body(...params: any[]): void;
|
||||
}
|
||||
|
||||
/** Represents a DocumentDB trigger. */
|
||||
export interface Trigger extends UniqueId {
|
||||
/** The type of the trigger. Should be either 'pre' or 'post'. */
|
||||
@@ -290,6 +301,19 @@ export declare class DocumentClient {
|
||||
*/
|
||||
public createStoredProcedure(collectionLink: string, procedure: Procedure, options: RequestOptions, callback: RequestCallback<ProcedureMeta>): void;
|
||||
|
||||
/**
|
||||
* Create a UserDefinedFunction.
|
||||
* <p>
|
||||
* DocumentDB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers. <br>
|
||||
* For additional details, refer to the server-side JavaScript API documentation.
|
||||
* </p>
|
||||
* @param collectionLink - The self-link of the collection.
|
||||
* @param udf - Represents the body of the userDefinedFunction.
|
||||
* @param [options] - The request options.
|
||||
* @param callback - The callback for the request.
|
||||
*/
|
||||
public createUserDefinedFunction(collectionLink: string, udf: UserDefinedFunction, options: RequestOptions, callback: RequestCallback<UserDefinedFunctionMeta>): void;
|
||||
|
||||
/**
|
||||
* Create a trigger.
|
||||
* <p>
|
||||
@@ -349,6 +373,15 @@ export declare class DocumentClient {
|
||||
*/
|
||||
public queryStoredProcedures(collectionLink: string, query: string | SqlQuerySpec): QueryIterator<ProcedureMeta>;
|
||||
|
||||
/**
|
||||
* Query the user-defined functions for the collection.
|
||||
* @param collectionLink - The self-link of the collection.
|
||||
* @param query - A SQL query string.
|
||||
* @param [options] - Represents the feed options.
|
||||
* @returns - An instance of queryIterator to handle reading feed.
|
||||
*/
|
||||
public queryUserDefinedFunctions(collectionLink: string, query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<UserDefinedFunctionMeta>;
|
||||
|
||||
/**
|
||||
* Query the documents for the collection.
|
||||
* @param collectionLink - The self-link of the collection.
|
||||
|
||||
Reference in New Issue
Block a user