Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion arangojs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ declare module "arangojs" {
* @param databaseName The name of the database to use.
*/
useDatabase(databaseName: string): any;
/**
* Updates the Database instance's `authorization` header to use Basic authentication with the given
* username and password, then returns itself.
*
* @param username The user name to log in with.
* @param password The password to use
*/
useBasicAuth(username: string, password: string): this;
/**
* Updates the Database instance's `authorization` header to use Bearer authentication with the given
* authentication token, then returns itself.
*
* @param {string} token
* @returns {this}
*
* @memberof Database
*/
useBearerAuth(token: string): this;
/**
* Creates a new database with the the given `databaseName`
*
Expand Down Expand Up @@ -98,7 +116,7 @@ declare module "arangojs" {
* @param bindVars An object defining the variables to bind the query to
* @param opts Additional options that will be passed to the query API
*/
query(query: string, bindVars?: any, opts?: any): Promise<Cursor>;
query(query: string | { query: string, bindVars?: any }, bindVars?: any, opts?: any): Promise<Cursor>;
/**
* Template string handler for AQL queries. Converts an ES2015 template string to an object that can be passed to `database.query` by converting arguments to bind variables
*
Expand Down Expand Up @@ -656,4 +674,16 @@ declare module "arangojs" {
*/
traversal(startVertex: string, opts: any): Promise<any>;
}

/**
* Template string tagging function.
*
* Usage:
```
import arangojs, {Database, aql} from 'arangojs';
let db = new Database();
let result = await db.query(aql`RETURN ${Date.now()}`);
```
*/
export function aql(t: TemplateStringsArray, ...params: any[]): { query: string, bindVars?: any };
}