Skip to content

Commit

Permalink
Merge pull request DefinitelyTyped#11134 from runceel/master
Browse files Browse the repository at this point in the history
[azure-mobile-apps]support execute custom sql query
  • Loading branch information
zhengbli authored Sep 9, 2016
2 parents 4008a51 + 35ab0fe commit fa1c063
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
12 changes: 11 additions & 1 deletion azure-mobile-apps/azure-mobile-apps-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,14 @@ mobileApps.logger.debug('a debug message')

// Query
queries.create('table').where({ x: 10 }).select('col1,col2');
mobileApps.query.create('table');
mobileApps.query.create('table');

// custom sql query
mobileApp.api.add('query', { authorize: true, get: (req, res, next) => {
req.azureMobile.data.execute({
sql: "SELECT * FROM TODOITEM WHERE COMPLETE = :complete",
parameters: [
{ name: 'complete', value: 1 }
]
}).then(x => {});
}, delete: function () {} });
17 changes: 16 additions & 1 deletion azure-mobile-apps/azure-mobile-apps.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,29 @@ declare namespace Azure.MobileApps {
item: any;
req: Express.Request;
res: Express.Response;
data: (table: TableDefinition) => Data.Table;
data: ContextData;
tables: (tableName: string) => Data.Table;
user: User;
push: typeof nh;
logger: Logger;
execute(): Thenable<any>;
}

interface ContextData {
(table: TableDefinition): Data.Table;
execute(q: SqlQueryDefinition): Thenable<any>;
}

interface SqlQueryDefinition {
sql: string;
parameters?: SqlParameterDefinition[];
}

interface SqlParameterDefinition {
name: string;
value: any;
}

interface TableDefinition {
authorize?: boolean;
autoIncrement?: boolean;
Expand Down

0 comments on commit fa1c063

Please sign in to comment.