@aws-amplify/datastore-storage-adapter 2.1.82 → 2.1.83-local-stack.00864ae.0
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/.rollup.cache/home/runner/work/amplify-js/amplify-js/amplify-js/packages/datastore-storage-adapter/dist/cjs/common/SQLiteUtils.js +14 -14
- package/.rollup.cache/home/runner/work/amplify-js/amplify-js/amplify-js/packages/datastore-storage-adapter/dist/meta/cjs.tsbuildinfo +1 -1
- package/dist/cjs/common/SQLiteUtils.js +14 -14
- package/dist/cjs/common/SQLiteUtils.js.map +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +46 -47
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.whereConditionFromPredicateObject = exports.implicitAuthFieldsForModel = void 0;
|
|
4
|
+
exports.getSQLiteType = getSQLiteType;
|
|
5
|
+
exports.generateSchemaStatements = generateSchemaStatements;
|
|
6
|
+
exports.modelCreateTableStatement = modelCreateTableStatement;
|
|
7
|
+
exports.modelInsertStatement = modelInsertStatement;
|
|
8
|
+
exports.modelUpdateStatement = modelUpdateStatement;
|
|
9
|
+
exports.queryByIdStatement = queryByIdStatement;
|
|
10
|
+
exports.whereClauseFromPredicate = whereClauseFromPredicate;
|
|
11
|
+
exports.orderByClauseFromSort = orderByClauseFromSort;
|
|
12
|
+
exports.limitClauseFromPagination = limitClauseFromPagination;
|
|
13
|
+
exports.queryAllStatement = queryAllStatement;
|
|
14
|
+
exports.queryOneStatement = queryOneStatement;
|
|
15
|
+
exports.deleteByIdStatement = deleteByIdStatement;
|
|
16
|
+
exports.deleteByPredicateStatement = deleteByPredicateStatement;
|
|
4
17
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
18
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
19
|
const datastore_1 = require("@aws-amplify/datastore");
|
|
@@ -64,7 +77,6 @@ function getSQLiteType(scalar) {
|
|
|
64
77
|
}
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
|
-
exports.getSQLiteType = getSQLiteType;
|
|
68
80
|
function generateSchemaStatements(schema) {
|
|
69
81
|
return Object.keys(schema.namespaces).flatMap(namespaceName => {
|
|
70
82
|
const namespace = schema.namespaces[namespaceName];
|
|
@@ -72,7 +84,6 @@ function generateSchemaStatements(schema) {
|
|
|
72
84
|
return Object.values(namespace.models).map(model => modelCreateTableStatement(model, isUserModel));
|
|
73
85
|
});
|
|
74
86
|
}
|
|
75
|
-
exports.generateSchemaStatements = generateSchemaStatements;
|
|
76
87
|
const implicitAuthFieldsForModel = (model) => {
|
|
77
88
|
if (!model.attributes || !model.attributes.length) {
|
|
78
89
|
return [];
|
|
@@ -141,24 +152,20 @@ function modelCreateTableStatement(model, userModel = false) {
|
|
|
141
152
|
const createTableStatement = `CREATE TABLE IF NOT EXISTS "${model.name}" (${fields.join(', ')});`;
|
|
142
153
|
return createTableStatement;
|
|
143
154
|
}
|
|
144
|
-
exports.modelCreateTableStatement = modelCreateTableStatement;
|
|
145
155
|
function modelInsertStatement(model, tableName) {
|
|
146
156
|
const keys = keysFromModel(model);
|
|
147
157
|
const [paramaterized, values] = valuesFromModel(model);
|
|
148
158
|
const insertStatement = `INSERT INTO "${tableName}" (${keys}) VALUES (${paramaterized})`;
|
|
149
159
|
return [insertStatement, values];
|
|
150
160
|
}
|
|
151
|
-
exports.modelInsertStatement = modelInsertStatement;
|
|
152
161
|
function modelUpdateStatement(model, tableName) {
|
|
153
162
|
const [paramaterized, values] = updateSet(model);
|
|
154
163
|
const updateStatement = `UPDATE "${tableName}" SET ${paramaterized} WHERE id=?`;
|
|
155
164
|
return [updateStatement, [...values, model.id]];
|
|
156
165
|
}
|
|
157
|
-
exports.modelUpdateStatement = modelUpdateStatement;
|
|
158
166
|
function queryByIdStatement(id, tableName) {
|
|
159
167
|
return [`SELECT * FROM "${tableName}" WHERE "id" = ?`, [id]];
|
|
160
168
|
}
|
|
161
|
-
exports.queryByIdStatement = queryByIdStatement;
|
|
162
169
|
/*
|
|
163
170
|
Predicates supported by DataStore:
|
|
164
171
|
|
|
@@ -281,7 +288,6 @@ function whereClauseFromPredicate(predicate) {
|
|
|
281
288
|
}
|
|
282
289
|
}
|
|
283
290
|
}
|
|
284
|
-
exports.whereClauseFromPredicate = whereClauseFromPredicate;
|
|
285
291
|
const sortDirectionMap = {
|
|
286
292
|
ASCENDING: 'ASC',
|
|
287
293
|
DESCENDING: 'DESC',
|
|
@@ -292,7 +298,6 @@ function orderByClauseFromSort(sortPredicate = []) {
|
|
|
292
298
|
orderByParts.push(`_rowid_ ${sortDirectionMap.ASCENDING}`);
|
|
293
299
|
return `ORDER BY ${orderByParts.join(', ')}`;
|
|
294
300
|
}
|
|
295
|
-
exports.orderByClauseFromSort = orderByClauseFromSort;
|
|
296
301
|
function limitClauseFromPagination(limit, page = 0) {
|
|
297
302
|
const params = [limit];
|
|
298
303
|
let clause = 'LIMIT ?';
|
|
@@ -303,7 +308,6 @@ function limitClauseFromPagination(limit, page = 0) {
|
|
|
303
308
|
}
|
|
304
309
|
return [clause, params];
|
|
305
310
|
}
|
|
306
|
-
exports.limitClauseFromPagination = limitClauseFromPagination;
|
|
307
311
|
function queryAllStatement(tableName, predicate, sort, limit, page) {
|
|
308
312
|
let statement = `SELECT * FROM "${tableName}"`;
|
|
309
313
|
const params = [];
|
|
@@ -321,7 +325,6 @@ function queryAllStatement(tableName, predicate, sort, limit, page) {
|
|
|
321
325
|
}
|
|
322
326
|
return [statement, params];
|
|
323
327
|
}
|
|
324
|
-
exports.queryAllStatement = queryAllStatement;
|
|
325
328
|
function queryOneStatement(firstOrLast, tableName) {
|
|
326
329
|
if (firstOrLast === datastore_1.QueryOne.FIRST) {
|
|
327
330
|
// ORDER BY rowid will no longer work as expected if a customer has
|
|
@@ -333,12 +336,10 @@ function queryOneStatement(firstOrLast, tableName) {
|
|
|
333
336
|
return [`SELECT * FROM ${tableName} ORDER BY _rowid_ DESC LIMIT 1`, []];
|
|
334
337
|
}
|
|
335
338
|
}
|
|
336
|
-
exports.queryOneStatement = queryOneStatement;
|
|
337
339
|
function deleteByIdStatement(id, tableName) {
|
|
338
340
|
const deleteStatement = `DELETE FROM "${tableName}" WHERE "id"=?`;
|
|
339
341
|
return [deleteStatement, [id]];
|
|
340
342
|
}
|
|
341
|
-
exports.deleteByIdStatement = deleteByIdStatement;
|
|
342
343
|
function deleteByPredicateStatement(tableName, predicate) {
|
|
343
344
|
let statement = `DELETE FROM "${tableName}"`;
|
|
344
345
|
const params = [];
|
|
@@ -349,4 +350,3 @@ function deleteByPredicateStatement(tableName, predicate) {
|
|
|
349
350
|
}
|
|
350
351
|
return [statement, params];
|
|
351
352
|
}
|
|
352
|
-
exports.deleteByPredicateStatement = deleteByPredicateStatement;
|