/
SqlQuerySpec.ts
39 lines (37 loc) · 1.12 KB
/
SqlQuerySpec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Represents a SQL query in the Azure Cosmos DB service.
*
* Queries with inputs should be parameterized to protect against SQL injection.
*
* @example Parameterized SQL Query
* ```typescript
* const query: SqlQuerySpec = {
* query: "SELECT * FROM Families f where f.lastName = @lastName",
* parameters: [
* {name: "@lastName", value: "Wakefield"}
* ]
* };
* ```
*/
export interface SqlQuerySpec {
/** The text of the SQL query */
query: string;
/** The parameters you provide in the query */
parameters?: SqlParameter[];
}
/**
* Represents a parameter in a Parameterized SQL query, specified in {@link SqlQuerySpec}
*/
export interface SqlParameter {
/** Name of the parameter. (i.e. "@lastName") */
name: string;
/** Value of the parameter (this is safe to come from users, assuming they are authorized) */
value: JSONValue;
}
export type JSONValue = boolean | number | string | null | JSONArray | JSONObject;
export interface JSONObject {
[key: string]: JSONValue;
}
export interface JSONArray extends Array<JSONValue> {}