couchset 0.0.0 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +231 -0
- package/dist/automate/index.d.ts +4 -0
- package/dist/automate/index.js +17 -0
- package/dist/automate/index.js.map +1 -0
- package/dist/automate/middlewares/index.d.ts +1 -0
- package/dist/automate/middlewares/index.js +14 -0
- package/dist/automate/middlewares/index.js.map +1 -0
- package/dist/automate/middlewares/isAuth.d.ts +7 -0
- package/dist/automate/middlewares/isAuth.js +28 -0
- package/dist/automate/middlewares/isAuth.js.map +1 -0
- package/dist/automate/model/client.d.ts +12 -0
- package/dist/automate/model/client.js +33 -0
- package/dist/automate/model/client.js.map +1 -0
- package/dist/automate/model/index.d.ts +44 -0
- package/dist/automate/model/index.js +304 -0
- package/dist/automate/model/index.js.map +1 -0
- package/dist/automate/morpheus/index.d.ts +14 -0
- package/dist/automate/morpheus/index.js +171 -0
- package/dist/automate/morpheus/index.js.map +1 -0
- package/dist/automate/writer/index.d.ts +10 -0
- package/dist/automate/writer/index.js +72 -0
- package/dist/automate/writer/index.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +8 -0
- package/dist/config/index.js.map +1 -0
- package/dist/connection.d.ts +36 -0
- package/dist/connection.js +129 -0
- package/dist/connection.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/model/index.d.ts +107 -0
- package/dist/model/index.js +329 -0
- package/dist/model/index.js.map +1 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +14 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/pagination/pagination.d.ts +19 -0
- package/dist/pagination/pagination.js +97 -0
- package/dist/pagination/pagination.js.map +1 -0
- package/dist/query/base-query.d.ts +17 -0
- package/dist/query/base-query.js +15 -0
- package/dist/query/base-query.js.map +1 -0
- package/dist/query/exceptions.d.ts +24 -0
- package/dist/query/exceptions.js +90 -0
- package/dist/query/exceptions.js.map +1 -0
- package/dist/query/helpers/builders.d.ts +64 -0
- package/dist/query/helpers/builders.js +415 -0
- package/dist/query/helpers/builders.js.map +1 -0
- package/dist/query/helpers/dictionary.d.ts +45 -0
- package/dist/query/helpers/dictionary.js +105 -0
- package/dist/query/helpers/dictionary.js.map +1 -0
- package/dist/query/helpers/index.d.ts +3 -0
- package/dist/query/helpers/index.js +16 -0
- package/dist/query/helpers/index.js.map +1 -0
- package/dist/query/helpers/reservedWords.d.ts +1 -0
- package/dist/query/helpers/reservedWords.js +200 -0
- package/dist/query/helpers/reservedWords.js.map +1 -0
- package/dist/query/index.d.ts +5 -0
- package/dist/query/index.js +27 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/interface/query.types.d.ts +236 -0
- package/dist/query/interface/query.types.js +3 -0
- package/dist/query/interface/query.types.js.map +1 -0
- package/dist/query/query.cluster.d.ts +14 -0
- package/dist/query/query.cluster.js +80 -0
- package/dist/query/query.cluster.js.map +1 -0
- package/dist/query/query.d.ts +321 -0
- package/dist/query/query.js +457 -0
- package/dist/query/query.js.map +1 -0
- package/dist/query/utils.d.ts +8 -0
- package/dist/query/utils.js +56 -0
- package/dist/query/utils.js.map +1 -0
- package/dist/search/customQuery.d.ts +17 -0
- package/dist/search/customQuery.js +83 -0
- package/dist/search/customQuery.js.map +1 -0
- package/dist/search/index.d.ts +1 -0
- package/dist/search/index.js +14 -0
- package/dist/search/index.js.map +1 -0
- package/dist/shared/ContextType.d.ts +27 -0
- package/dist/shared/ContextType.js +55 -0
- package/dist/shared/ContextType.js.map +1 -0
- package/dist/shared/common.model.d.ts +37 -0
- package/dist/shared/common.model.js +148 -0
- package/dist/shared/common.model.js.map +1 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +15 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/utils/awaitTo.d.ts +17 -0
- package/dist/utils/awaitTo.js +31 -0
- package/dist/utils/awaitTo.js.map +1 -0
- package/dist/utils/date.d.ts +11 -0
- package/dist/utils/date.js +21 -0
- package/dist/utils/date.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/log.d.ts +9 -0
- package/dist/utils/log.js +19 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/text.utils.d.ts +14 -0
- package/dist/utils/text.utils.js +45 -0
- package/dist/utils/text.utils.js.map +1 -0
- package/dist/utils/utils.schema.d.ts +6 -0
- package/dist/utils/utils.schema.js +33 -0
- package/dist/utils/utils.schema.js.map +1 -0
- package/dist/uuid.d.ts +1 -0
- package/dist/uuid.js +9 -0
- package/dist/uuid.js.map +1 -0
- package/docs/couch.png +0 -0
- package/docs/couchset.png +0 -0
- package/docs/couchset_logo.png +0 -0
- package/package.json +108 -30
- package/register/index.js +1 -0
- package/register/transpile-only.js +3 -0
- package/register/type-check.js +3 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { QueryResult } from 'couchbase';
|
|
2
|
+
/**
|
|
3
|
+
* Query couchbase db
|
|
4
|
+
* @param query
|
|
5
|
+
*
|
|
6
|
+
const query = `
|
|
7
|
+
SELECT airportname, city FROM \`travel-sample\`
|
|
8
|
+
WHERE type=$1
|
|
9
|
+
AND city=$2
|
|
10
|
+
`;
|
|
11
|
+
const options = {parameters: ['airport', 'San Jose']};
|
|
12
|
+
* @param options
|
|
13
|
+
*/
|
|
14
|
+
export declare function QueryCluster(query: string, options?: any): Promise<QueryResult>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.QueryCluster = void 0;
|
|
43
|
+
var connection_1 = __importDefault(require("../connection"));
|
|
44
|
+
/**
|
|
45
|
+
* Query couchbase db
|
|
46
|
+
* @param query
|
|
47
|
+
*
|
|
48
|
+
const query = `
|
|
49
|
+
SELECT airportname, city FROM \`travel-sample\`
|
|
50
|
+
WHERE type=$1
|
|
51
|
+
AND city=$2
|
|
52
|
+
`;
|
|
53
|
+
const options = {parameters: ['airport', 'San Jose']};
|
|
54
|
+
* @param options
|
|
55
|
+
*/
|
|
56
|
+
function QueryCluster(query, options) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var cluster, result, error_1;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
cluster = connection_1.default.Instance.cluster;
|
|
63
|
+
_a.label = 1;
|
|
64
|
+
case 1:
|
|
65
|
+
_a.trys.push([1, 3, , 4]);
|
|
66
|
+
return [4 /*yield*/, cluster.query(query, options)];
|
|
67
|
+
case 2:
|
|
68
|
+
result = _a.sent();
|
|
69
|
+
return [2 /*return*/, result];
|
|
70
|
+
case 3:
|
|
71
|
+
error_1 = _a.sent();
|
|
72
|
+
console.error('Query failed: ', error_1);
|
|
73
|
+
throw error_1;
|
|
74
|
+
case 4: return [2 /*return*/];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
exports.QueryCluster = QueryCluster;
|
|
80
|
+
//# sourceMappingURL=query.cluster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.cluster.js","sourceRoot":"","sources":["../../src/query/query.cluster.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6DAAgD;AAEhD;;;;;;;;;;;GAWG;AACH,SAAsB,YAAY,CAAC,KAAa,EAAE,OAAa;;;;;;oBACrD,OAAO,GAAG,oBAAmB,CAAC,QAAQ,CAAC,OAAO,CAAC;;;;oBAElC,qBAAM,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,EAAA;;oBAA5C,MAAM,GAAG,SAAmC;oBAClD,sBAAO,MAAM,EAAC;;;oBAEd,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAK,CAAC,CAAC;oBACvC,MAAM,OAAK,CAAC;;;;;CAEnB;AATD,oCASC","sourcesContent":["import {QueryResult} from 'couchbase';\n\nimport CouchbaseConnection from '../connection';\n\n/**\n * Query couchbase db\n * @param query\n * \n const query = `\n SELECT airportname, city FROM \\`travel-sample\\`\n WHERE type=$1\n AND city=$2\n `;\n const options = {parameters: ['airport', 'San Jose']};\n * @param options\n */\nexport async function QueryCluster(query: string, options?: any): Promise<QueryResult> {\n const cluster = CouchbaseConnection.Instance.cluster;\n try {\n const result = await cluster.query(query, options);\n return result;\n } catch (error) {\n console.error('Query failed: ', error);\n throw error;\n }\n}\n"]}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { BaseQuery } from './base-query';
|
|
2
|
+
import { IConditionExpr, IGroupBy, IIndexOnParams, IIndexWithParams, ILetExpr, IndexType, ISelectType, LogicalWhereExpr, SortType } from './interface/query.types';
|
|
3
|
+
export declare class QueryBuilder extends BaseQuery {
|
|
4
|
+
/**
|
|
5
|
+
* SELECT Expression.
|
|
6
|
+
*/
|
|
7
|
+
private selectExpr?;
|
|
8
|
+
/**
|
|
9
|
+
* WHERE Expression.
|
|
10
|
+
*/
|
|
11
|
+
private whereExpr?;
|
|
12
|
+
/**
|
|
13
|
+
* ORDER BY Expression.
|
|
14
|
+
*/
|
|
15
|
+
private orderExpr?;
|
|
16
|
+
/**
|
|
17
|
+
* LIMIT Expression.
|
|
18
|
+
*/
|
|
19
|
+
private limitExpr?;
|
|
20
|
+
/**
|
|
21
|
+
* OFFSET Expression.
|
|
22
|
+
*/
|
|
23
|
+
private offSetExpr?;
|
|
24
|
+
/**
|
|
25
|
+
* LET Expression.
|
|
26
|
+
*/
|
|
27
|
+
private letExpr?;
|
|
28
|
+
/**
|
|
29
|
+
* GROUP BY Expression.
|
|
30
|
+
*/
|
|
31
|
+
private groupByExpr?;
|
|
32
|
+
/**
|
|
33
|
+
* LETTING Expression.
|
|
34
|
+
*/
|
|
35
|
+
private lettingExpr?;
|
|
36
|
+
/**
|
|
37
|
+
* HAVING Expression.
|
|
38
|
+
*/
|
|
39
|
+
private havingExpr?;
|
|
40
|
+
/**
|
|
41
|
+
* Plain JOIN Expression.
|
|
42
|
+
*/
|
|
43
|
+
private plainJoinExpr?;
|
|
44
|
+
/**
|
|
45
|
+
* USE Expression.
|
|
46
|
+
*/
|
|
47
|
+
private useKeysExpr?;
|
|
48
|
+
/**
|
|
49
|
+
* Available query types.
|
|
50
|
+
*/
|
|
51
|
+
private queryType?;
|
|
52
|
+
/**
|
|
53
|
+
* INDEX ON Expression.
|
|
54
|
+
*/
|
|
55
|
+
private indexOn?;
|
|
56
|
+
/**
|
|
57
|
+
* Types of supported index statements.
|
|
58
|
+
*/
|
|
59
|
+
private indexType?;
|
|
60
|
+
/**
|
|
61
|
+
* Index name.
|
|
62
|
+
*/
|
|
63
|
+
private indexName?;
|
|
64
|
+
/**
|
|
65
|
+
* INDEX USING GSI Expression.
|
|
66
|
+
*/
|
|
67
|
+
private indexUsingGSI?;
|
|
68
|
+
/**
|
|
69
|
+
* INDEX USING GSI Expression.
|
|
70
|
+
*/
|
|
71
|
+
private indexWith?;
|
|
72
|
+
/**
|
|
73
|
+
* @summary Create an instance of QueryBuilder.
|
|
74
|
+
* @name QueryBuilder
|
|
75
|
+
* @class
|
|
76
|
+
* @public
|
|
77
|
+
*
|
|
78
|
+
* @param conditions List of SELECT clause conditions
|
|
79
|
+
* @param collection Collection name
|
|
80
|
+
* @returns QueryBuilder
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const query = new QueryBuilder({$select: [{$field: 'address'}], $where: {$nill: [{ address: { $like: '%57-59%' } }, { free_breakfast: true }, { free_lunch: [1] }]}}, 'travel-sample');
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
constructor(conditions: IConditionExpr, collection: string);
|
|
88
|
+
/**
|
|
89
|
+
* Add result selectors to SELECT clause.
|
|
90
|
+
* @method
|
|
91
|
+
* @public
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const query = new QueryBuilder({}, 'travel-sample');
|
|
96
|
+
* const result = query.select([{$field: 'address'}]).build()
|
|
97
|
+
* console.log(result)
|
|
98
|
+
* ```
|
|
99
|
+
* > SELECT address FROM `travel-sample`
|
|
100
|
+
*/
|
|
101
|
+
select(value?: ISelectType[] | string | undefined): QueryBuilder;
|
|
102
|
+
/**
|
|
103
|
+
* Add index type and name to INDEX clause.
|
|
104
|
+
* @method
|
|
105
|
+
* @public
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const result = new QueryBuilder({}, 'travel-sample').index('DROP', 'travel_sample_id_test').build();
|
|
110
|
+
* console.log(result)
|
|
111
|
+
* ```
|
|
112
|
+
* > DROP INDEX `travel-sample`.`travel_sample_id_test`
|
|
113
|
+
*/
|
|
114
|
+
index(type: IndexType, name: string): QueryBuilder;
|
|
115
|
+
/**
|
|
116
|
+
* Add items to ON clause in INDEX clause.
|
|
117
|
+
* @method
|
|
118
|
+
* @public
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* const on = [{ name: 'travel-sample.callsing', sort: 'ASC' }];
|
|
123
|
+
* const result = new QueryBuilder({}, 'travel-sample').index('CREATE', 'travel_sample_id_test').on(on).build();
|
|
124
|
+
* console.log(result)
|
|
125
|
+
* ```
|
|
126
|
+
* > CREATE INDEX `travel_sample_id_test` ON `travel-sample`(`travel-sample.callsing`['ASC'])
|
|
127
|
+
*/
|
|
128
|
+
on(value: IIndexOnParams[]): QueryBuilder;
|
|
129
|
+
/**
|
|
130
|
+
* Create INDEX using General Secondary Index(GSI).
|
|
131
|
+
* @method
|
|
132
|
+
* @public
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* const result = new QueryBuilder({}, 'travel-sample').index('CREATE', 'travel_sample_id_test').usingGSI().build();
|
|
137
|
+
* console.log(result)
|
|
138
|
+
* ```
|
|
139
|
+
* > CREATE INDEX `travel_sample_id_test` USING GSI)
|
|
140
|
+
*/
|
|
141
|
+
usingGSI(): QueryBuilder;
|
|
142
|
+
/**
|
|
143
|
+
* Add items to WITH clause in INDEX clause.
|
|
144
|
+
* @method
|
|
145
|
+
* @public
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* const withExpr = {nodes: ['192.168.1.1:8078'],defer_build: true,num_replica: 2};
|
|
150
|
+
* const result = new QueryBuilder({}, 'travel-sample').index('CREATE', 'travel_sample_id_test').with(withExpr).build();
|
|
151
|
+
* console.log(result)
|
|
152
|
+
* ```
|
|
153
|
+
* > CREATE INDEX `travel_sample_id_test` WITH {'nodes': ['192.168.1.1:8078'],'defer_build': true,'num_replica': 2})
|
|
154
|
+
*/
|
|
155
|
+
with(value: IIndexWithParams): QueryBuilder;
|
|
156
|
+
/**
|
|
157
|
+
* Add WHERE expression to SELECT clause.
|
|
158
|
+
* @method
|
|
159
|
+
* @public
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const expr_where = {$or: [{ address: { $like: '%57-59%' } }, { free_breakfast: true }]};
|
|
164
|
+
* const query = new QueryBuilder({}, 'travel-sample');
|
|
165
|
+
* const result = query.select([{$field: 'address'}]).where(expr_where).build()
|
|
166
|
+
* console.log(result)
|
|
167
|
+
* ```
|
|
168
|
+
* > SELECT address FROM `travel-sample WHERE (address LIKE '%57-59%' OR free_breakfast = true)`
|
|
169
|
+
*/
|
|
170
|
+
where(value: LogicalWhereExpr): QueryBuilder;
|
|
171
|
+
/**
|
|
172
|
+
* Add JOIN expression to SELECT clause.
|
|
173
|
+
* @method
|
|
174
|
+
* @public
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```tS
|
|
178
|
+
* const query = new QueryBuilder({}, 'beer-sample brewery');
|
|
179
|
+
* const result = query.select([{$field: 'address'}]).plainJoin('JOIN `beer-sample` beer ON beer.brewery_id = LOWER(REPLACE(brewery.name, " ", "_"))').build()
|
|
180
|
+
* console.log(result)
|
|
181
|
+
* ```
|
|
182
|
+
* > SELECT address FROM `beer-sample brewery` JOIN `beer-sample` beer ON beer.brewery_id = LOWER(REPLACE(brewery.name, " ", "_")) LIMIT 1`
|
|
183
|
+
*/
|
|
184
|
+
plainJoin(value: string): QueryBuilder;
|
|
185
|
+
/**
|
|
186
|
+
* Add ORDER BY expression to SELECT clause.
|
|
187
|
+
* @method
|
|
188
|
+
* @public
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const query = new QueryBuilder({}, 'travel-sample');
|
|
193
|
+
* const result = query.select([{$field: 'address'}]).orderBy({ size: 'DESC' }).build()
|
|
194
|
+
* console.log(result)
|
|
195
|
+
* ```
|
|
196
|
+
* > SELECT address FROM `travel-sample ORDER BY size = 'DESC'`
|
|
197
|
+
*/
|
|
198
|
+
orderBy(value: Record<string, SortType>): QueryBuilder;
|
|
199
|
+
/**
|
|
200
|
+
* Add LIMIT expression to SELECT clause.
|
|
201
|
+
* @method
|
|
202
|
+
* @public
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* const query = new QueryBuilder({}, 'travel-sample');
|
|
207
|
+
* const result = query.select([{$field: 'address'}]).limit(10).build()
|
|
208
|
+
* console.log(result)
|
|
209
|
+
* ```
|
|
210
|
+
* > SELECT address FROM `travel-sample LIMIT 10`
|
|
211
|
+
*/
|
|
212
|
+
limit(value: number): QueryBuilder;
|
|
213
|
+
/**
|
|
214
|
+
* Add OFFSET expression to SELECT clause.
|
|
215
|
+
* @method
|
|
216
|
+
* @public
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* const query = new QueryBuilder({}, 'travel-sample');
|
|
221
|
+
* const result = query.select([{$field: 'address'}]).offset(10).build()
|
|
222
|
+
* console.log(result)
|
|
223
|
+
* ```
|
|
224
|
+
* > SELECT address FROM `travel-sample OFFSET 10`
|
|
225
|
+
*/
|
|
226
|
+
offset(value: number): QueryBuilder;
|
|
227
|
+
/**
|
|
228
|
+
* Add LET expression to SELECT clause.
|
|
229
|
+
* @method
|
|
230
|
+
* @public
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```ts
|
|
234
|
+
* const letExpr = [{ key: 'amount_val', value: 10 }];
|
|
235
|
+
* const query = new QueryBuilder({}, 'travel-sample');
|
|
236
|
+
* const result = query.select([{$field: 'address'}]).let(letExpr).build()
|
|
237
|
+
* console.log(result)
|
|
238
|
+
* ```
|
|
239
|
+
* > SELECT address FROM `travel-sample LET amount_val = 10`
|
|
240
|
+
*/
|
|
241
|
+
let(value: ILetExpr[]): QueryBuilder;
|
|
242
|
+
/**
|
|
243
|
+
* Add GROUP BY expression to GROUP BY clause.
|
|
244
|
+
* @method
|
|
245
|
+
* @public
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```ts
|
|
249
|
+
* const groupByExpr = [{ expr: 'COUNT(amount_val)', as: 'amount' }];
|
|
250
|
+
* const query = new QueryBuilder({}, 'travel-sample');
|
|
251
|
+
* const result = query.select([{$field: 'address'}]).groupBy(groupByExpr).build()
|
|
252
|
+
* console.log(result)
|
|
253
|
+
* ```
|
|
254
|
+
* > SELECT address FROM `travel-sample GROUP BY COUNT(amount) AS amount`
|
|
255
|
+
*/
|
|
256
|
+
groupBy(value: IGroupBy[]): QueryBuilder;
|
|
257
|
+
/**
|
|
258
|
+
* Add LETTING expression to GROUP BY clause.
|
|
259
|
+
* @method
|
|
260
|
+
* @public
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* const groupByExpr = [{ expr: 'COUNT(amount_val)', as: 'amount' }];
|
|
265
|
+
* const letExpr = [{ key: 'amount_val', value: 10 }];
|
|
266
|
+
* const query = new QueryBuilder({}, 'travel-sample');
|
|
267
|
+
* const result = query.select([{$field: 'address'}]).groupBy(groupByExpr).let(letExpr).build()
|
|
268
|
+
* console.log(result)
|
|
269
|
+
* ```
|
|
270
|
+
* > SELECT address FROM `travel-sample GROUP BY COUNT(amount) AS amount LETTING amount = 10`
|
|
271
|
+
*/
|
|
272
|
+
letting(value: ILetExpr[]): QueryBuilder;
|
|
273
|
+
/**
|
|
274
|
+
* Add HAVING expression to GROUP BY clause.
|
|
275
|
+
* @method
|
|
276
|
+
* @public
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```ts
|
|
280
|
+
* const groupByExpr = [{ expr: 'COUNT(amount_val)', as: 'amount' }];
|
|
281
|
+
* const having = {address: {$like: '%58%'}};
|
|
282
|
+
* const query = new QueryBuilder({}, 'travel-sample');
|
|
283
|
+
* const result = query.select([{$field: 'address'}]).groupBy(groupByExpr).having(having).build()
|
|
284
|
+
* console.log(result)
|
|
285
|
+
* ```
|
|
286
|
+
* > SELECT address FROM `travel-sample GROUP BY COUNT(amount) AS amount HAVING address LIKE '%58%'`
|
|
287
|
+
*/
|
|
288
|
+
having(value: LogicalWhereExpr): QueryBuilder;
|
|
289
|
+
/**
|
|
290
|
+
* Add USE KEYS expression to SELECT clause.
|
|
291
|
+
* @method
|
|
292
|
+
* @public
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* const query = new QueryBuilder({}, 'travel-sample');
|
|
297
|
+
* const result = query.select([{$field: 'address'}]).useKeys(['airlineR_8093']).build()
|
|
298
|
+
* console.log(result)
|
|
299
|
+
* ```
|
|
300
|
+
* > SELECT address FROM `travel-sample USE KEYS ['airlineR_8093']`
|
|
301
|
+
*/
|
|
302
|
+
useKeys(value: string[]): QueryBuilder;
|
|
303
|
+
/**
|
|
304
|
+
* Converts the conditional parameters passed to the constructor to the properties of the N1QL QueryBuilder.
|
|
305
|
+
* @method
|
|
306
|
+
* @public
|
|
307
|
+
*
|
|
308
|
+
*/
|
|
309
|
+
compileFromConditions(conditionals: IConditionExpr): void;
|
|
310
|
+
/**
|
|
311
|
+
* Build a n1ql query from the defined parameters.
|
|
312
|
+
* @method
|
|
313
|
+
* @public
|
|
314
|
+
*
|
|
315
|
+
*/
|
|
316
|
+
build(): string;
|
|
317
|
+
get conditions(): IConditionExpr;
|
|
318
|
+
set conditions(value: IConditionExpr);
|
|
319
|
+
get collection(): string;
|
|
320
|
+
set collection(value: string);
|
|
321
|
+
}
|