tinybase 10.0.0-beta.0 → 10.0.0-beta.2
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/@types/common/index.d.ts +1 -0
- package/@types/common/with-schemas/index.d.ts +1 -0
- package/@types/indexes/index.d.ts +4 -3
- package/@types/indexes/with-schemas/index.d.ts +4 -3
- package/@types/metrics/index.d.ts +1 -0
- package/@types/metrics/with-schemas/index.d.ts +1 -0
- package/@types/omni/index.d.ts +1 -0
- package/@types/omni/with-schemas/index.d.ts +1 -0
- package/@types/persisters/index.d.ts +1 -0
- package/@types/persisters/persister-partykit-server/index.d.ts +17 -0
- package/@types/persisters/persister-partykit-server/with-schemas/index.d.ts +17 -0
- package/@types/persisters/persister-tinyjoin/index.d.ts +197 -0
- package/@types/persisters/persister-tinyjoin/with-schemas/index.d.ts +221 -0
- package/@types/persisters/with-schemas/index.d.ts +1 -0
- package/@types/queries/index.d.ts +3 -0
- package/@types/queries/with-schemas/index.d.ts +3 -0
- package/@types/relationships/index.d.ts +1 -0
- package/@types/relationships/with-schemas/index.d.ts +1 -0
- package/@types/store/index.d.ts +4 -0
- package/@types/store/with-schemas/index.d.ts +4 -0
- package/@types/ui-react/index.d.ts +2 -0
- package/@types/ui-react/with-schemas/index.d.ts +1 -0
- package/@types/ui-react-dom-charts/index.d.ts +7 -0
- package/@types/ui-react-dom-charts/with-schemas/index.d.ts +7 -0
- package/@types/ui-solid/index.d.ts +2 -0
- package/@types/ui-solid/with-schemas/index.d.ts +1 -0
- package/@types/ui-svelte/index.d.ts +23 -0
- package/@types/ui-svelte/with-schemas/index.d.ts +23 -0
- package/@types/ui-svelte-dom/index.d.ts +10 -0
- package/@types/ui-svelte-dom/with-schemas/index.d.ts +10 -0
- package/@types/ui-svelte-inspector/index.d.ts +1 -0
- package/@types/ui-svelte-inspector/with-schemas/index.d.ts +1 -0
- package/checkpoints/index.js +4 -2
- package/checkpoints/with-schemas/index.js +4 -2
- package/index.js +37 -4
- package/metrics/index.js +2 -1
- package/metrics/with-schemas/index.js +2 -1
- package/min/checkpoints/index.js +1 -1
- package/min/checkpoints/index.js.gz +0 -0
- package/min/checkpoints/with-schemas/index.js +1 -1
- package/min/checkpoints/with-schemas/index.js.gz +0 -0
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/metrics/index.js +1 -1
- package/min/metrics/index.js.gz +0 -0
- package/min/metrics/with-schemas/index.js +1 -1
- package/min/metrics/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/persisters/index.js +1 -1
- package/min/persisters/index.js.gz +0 -0
- package/min/persisters/persister-better-sqlite3/index.js +1 -1
- package/min/persisters/persister-better-sqlite3/index.js.gz +0 -0
- package/min/persisters/persister-better-sqlite3/with-schemas/index.js +1 -1
- package/min/persisters/persister-better-sqlite3/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-capacitor-sqlite/index.js +1 -1
- package/min/persisters/persister-capacitor-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-capacitor-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-capacitor-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/index.js +1 -1
- package/min/persisters/persister-electric-sql/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/with-schemas/index.js +1 -1
- package/min/persisters/persister-electric-sql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-libsql/index.js +1 -1
- package/min/persisters/persister-libsql/index.js.gz +0 -0
- package/min/persisters/persister-libsql/with-schemas/index.js +1 -1
- package/min/persisters/persister-libsql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-pg/index.js +1 -1
- package/min/persisters/persister-pg/index.js.gz +0 -0
- package/min/persisters/persister-pg/with-schemas/index.js +1 -1
- package/min/persisters/persister-pg/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-pglite/index.js +1 -1
- package/min/persisters/persister-pglite/index.js.gz +0 -0
- package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
- package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-postgres/index.js +1 -1
- package/min/persisters/persister-postgres/index.js.gz +0 -0
- package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
- package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-powersync/index.js +1 -1
- package/min/persisters/persister-powersync/index.js.gz +0 -0
- package/min/persisters/persister-powersync/with-schemas/index.js +1 -1
- package/min/persisters/persister-powersync/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/index.js +1 -1
- package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-node/index.js +1 -1
- package/min/persisters/persister-sqlite-node/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-node/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-node/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/index.js +1 -1
- package/min/persisters/persister-sqlite3/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite3/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-tinyjoin/index.js +1 -0
- package/min/persisters/persister-tinyjoin/index.js.gz +0 -0
- package/min/persisters/persister-tinyjoin/with-schemas/index.js +1 -0
- package/min/persisters/persister-tinyjoin/with-schemas/index.js.gz +0 -0
- package/min/persisters/with-schemas/index.js +1 -1
- package/min/persisters/with-schemas/index.js.gz +0 -0
- package/min/queries/index.js +1 -1
- package/min/queries/index.js.gz +0 -0
- package/min/queries/with-schemas/index.js +1 -1
- package/min/queries/with-schemas/index.js.gz +0 -0
- package/min/relationships/index.js +1 -1
- package/min/relationships/index.js.gz +0 -0
- package/min/relationships/with-schemas/index.js +1 -1
- package/min/relationships/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/index.js +1 -1
- package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +205 -94
- package/omni/with-schemas/index.js +205 -94
- package/package.json +54 -14
- package/persisters/index.js +28 -13
- package/persisters/persister-better-sqlite3/index.js +70 -55
- package/persisters/persister-better-sqlite3/with-schemas/index.js +70 -55
- package/persisters/persister-capacitor-sqlite/index.js +70 -55
- package/persisters/persister-capacitor-sqlite/with-schemas/index.js +70 -55
- package/persisters/persister-cr-sqlite-wasm/index.js +70 -55
- package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +70 -55
- package/persisters/persister-durable-object-sql-storage/index.js +28 -13
- package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +28 -13
- package/persisters/persister-electric-sql/index.js +70 -55
- package/persisters/persister-electric-sql/with-schemas/index.js +70 -55
- package/persisters/persister-expo-sqlite/index.js +70 -55
- package/persisters/persister-expo-sqlite/with-schemas/index.js +70 -55
- package/persisters/persister-libsql/index.js +91 -78
- package/persisters/persister-libsql/with-schemas/index.js +91 -78
- package/persisters/persister-pg/index.js +77 -62
- package/persisters/persister-pg/with-schemas/index.js +77 -62
- package/persisters/persister-pglite/index.js +28 -13
- package/persisters/persister-pglite/with-schemas/index.js +28 -13
- package/persisters/persister-postgres/index.js +28 -13
- package/persisters/persister-postgres/with-schemas/index.js +28 -13
- package/persisters/persister-powersync/index.js +81 -66
- package/persisters/persister-powersync/with-schemas/index.js +81 -66
- package/persisters/persister-react-native-sqlite/index.js +70 -55
- package/persisters/persister-react-native-sqlite/with-schemas/index.js +70 -55
- package/persisters/persister-sqlite-bun/index.js +70 -55
- package/persisters/persister-sqlite-bun/with-schemas/index.js +70 -55
- package/persisters/persister-sqlite-node/index.js +70 -55
- package/persisters/persister-sqlite-node/with-schemas/index.js +70 -55
- package/persisters/persister-sqlite-wasm/index.js +70 -55
- package/persisters/persister-sqlite-wasm/with-schemas/index.js +70 -55
- package/persisters/persister-sqlite3/index.js +70 -55
- package/persisters/persister-sqlite3/with-schemas/index.js +70 -55
- package/persisters/persister-tinyjoin/index.js +1710 -0
- package/persisters/persister-tinyjoin/with-schemas/index.js +1710 -0
- package/persisters/with-schemas/index.js +28 -13
- package/queries/index.js +2 -1
- package/queries/with-schemas/index.js +2 -1
- package/readme.md +3 -3
- package/relationships/index.js +39 -9
- package/relationships/with-schemas/index.js +39 -9
- package/releases.md +20 -1
- package/synchronizers/synchronizer-local/index.js +1 -1
- package/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/with-schemas/index.js +37 -4
|
@@ -92,57 +92,6 @@ const arrayClear = (array, to = size(array)) => array.splice(0, to);
|
|
|
92
92
|
const arrayPush = (array, ...values) => array.push(...values);
|
|
93
93
|
const arrayShift = (array) => array.shift();
|
|
94
94
|
|
|
95
|
-
const SINGLE_ROW_ID = '_';
|
|
96
|
-
const DEFAULT_ROW_ID_COLUMN_NAME = '_id';
|
|
97
|
-
const SELECT = 'SELECT';
|
|
98
|
-
const WHERE = 'WHERE';
|
|
99
|
-
const TABLE = 'TABLE';
|
|
100
|
-
const INSERT = 'INSERT';
|
|
101
|
-
const DELETE = 'DELETE';
|
|
102
|
-
const UPDATE = 'UPDATE';
|
|
103
|
-
const ALTER_TABLE = 'ALTER ' + TABLE;
|
|
104
|
-
const FROM = 'FROM';
|
|
105
|
-
const DELETE_FROM = DELETE + ' ' + FROM;
|
|
106
|
-
const SELECT_STAR_FROM = SELECT + '*' + FROM;
|
|
107
|
-
const CREATE = 'CREATE ';
|
|
108
|
-
const CREATE_TABLE = CREATE + TABLE;
|
|
109
|
-
const OR_REPLACE = 'OR REPLACE ';
|
|
110
|
-
const FUNCTION = 'FUNCTION';
|
|
111
|
-
const TABLE_NAME_PLACEHOLDER_REGEX = /\$tableName/g;
|
|
112
|
-
const getWrappedCommand = (executeCommand, onSqlCommand) =>
|
|
113
|
-
onSqlCommand
|
|
114
|
-
? async (sql, params) => {
|
|
115
|
-
onSqlCommand(sql, params);
|
|
116
|
-
return await executeCommand(sql, params);
|
|
117
|
-
}
|
|
118
|
-
: executeCommand;
|
|
119
|
-
const escapeId = (str) =>
|
|
120
|
-
arrayJoin(
|
|
121
|
-
arrayMap(strSplit(str, DOT), (part) => `"${strReplace(part, /"/g, '""')}"`),
|
|
122
|
-
DOT,
|
|
123
|
-
);
|
|
124
|
-
const escapeIds = (...ids) => escapeId(arrayJoin(ids, '_'));
|
|
125
|
-
const escapeColumnNames = (...columnNames) =>
|
|
126
|
-
arrayJoin(arrayMap(columnNames, escapeId), COMMA);
|
|
127
|
-
const numberedPlaceholder = (offset) => '$' + offset[0]++;
|
|
128
|
-
const getPlaceholders = (array, getPlaceholder, offset = [1]) =>
|
|
129
|
-
arrayJoin(
|
|
130
|
-
arrayMap(array, () => getPlaceholder(offset)),
|
|
131
|
-
COMMA,
|
|
132
|
-
);
|
|
133
|
-
const getWhereCondition = (tableName, condition = TRUE) =>
|
|
134
|
-
WHERE + `(${replaceTableName(condition, escapeId(tableName))})`;
|
|
135
|
-
const replaceTableName = (condition, tableName) =>
|
|
136
|
-
strReplace(condition, TABLE_NAME_PLACEHOLDER_REGEX, tableName);
|
|
137
|
-
|
|
138
|
-
const collSize = (coll) => coll?.size ?? 0;
|
|
139
|
-
const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
|
|
140
|
-
const collIsEmpty = (coll) => isUndefined(coll) || collSize(coll) == 0;
|
|
141
|
-
const collValues = (coll) => [...(coll?.values() ?? [])];
|
|
142
|
-
const collClear = (coll) => coll.clear();
|
|
143
|
-
const collForEach = (coll, cb) => coll?.forEach(cb);
|
|
144
|
-
const collDel = (coll, keyOrValue) => coll?.delete(keyOrValue);
|
|
145
|
-
|
|
146
95
|
const object = Object;
|
|
147
96
|
const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
|
|
148
97
|
const objEntries = object.entries;
|
|
@@ -192,6 +141,69 @@ const objValues = (obj) => object.values(obj);
|
|
|
192
141
|
const objSize = (obj) => size(objIds(obj));
|
|
193
142
|
const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
|
|
194
143
|
|
|
144
|
+
const SINGLE_ROW_ID = '_';
|
|
145
|
+
const DEFAULT_ROW_ID_COLUMN_NAME = '_id';
|
|
146
|
+
const SELECT = 'SELECT';
|
|
147
|
+
const WHERE = 'WHERE';
|
|
148
|
+
const TABLE = 'TABLE';
|
|
149
|
+
const INSERT = 'INSERT';
|
|
150
|
+
const DELETE = 'DELETE';
|
|
151
|
+
const UPDATE = 'UPDATE';
|
|
152
|
+
const ALTER_TABLE = 'ALTER ' + TABLE;
|
|
153
|
+
const FROM = 'FROM';
|
|
154
|
+
const DELETE_FROM = DELETE + ' ' + FROM;
|
|
155
|
+
const SELECT_STAR_FROM = SELECT + '*' + FROM;
|
|
156
|
+
const CREATE = 'CREATE ';
|
|
157
|
+
const CREATE_TABLE = CREATE + TABLE;
|
|
158
|
+
const OR_REPLACE = 'OR REPLACE ';
|
|
159
|
+
const FUNCTION = 'FUNCTION';
|
|
160
|
+
const TABLE_NAME_PLACEHOLDER_REGEX = /\$tableName/g;
|
|
161
|
+
const getWrappedCommand = (executeCommand, onSqlCommand) =>
|
|
162
|
+
onSqlCommand
|
|
163
|
+
? async (sql, params) => {
|
|
164
|
+
onSqlCommand(sql, params);
|
|
165
|
+
return await executeCommand(sql, params);
|
|
166
|
+
}
|
|
167
|
+
: executeCommand;
|
|
168
|
+
const escapeId = (str) =>
|
|
169
|
+
arrayJoin(
|
|
170
|
+
arrayMap(strSplit(str, DOT), (part) => `"${strReplace(part, /"/g, '""')}"`),
|
|
171
|
+
DOT,
|
|
172
|
+
);
|
|
173
|
+
const escapeIds = (...ids) => escapeId(arrayJoin(ids, '_'));
|
|
174
|
+
const escapeColumnNames = (...columnNames) =>
|
|
175
|
+
arrayJoin(arrayMap(columnNames, escapeId), COMMA);
|
|
176
|
+
const numberedPlaceholder = (offset) => '$' + offset[0]++;
|
|
177
|
+
const getPlaceholders = (array, getPlaceholder, offset = [1]) =>
|
|
178
|
+
arrayJoin(
|
|
179
|
+
arrayMap(array, () => getPlaceholder(offset)),
|
|
180
|
+
COMMA,
|
|
181
|
+
);
|
|
182
|
+
const getWhere = (tableName, condition = TRUE, extraCondition) => {
|
|
183
|
+
const conditions = arrayFilter(
|
|
184
|
+
[
|
|
185
|
+
condition == TRUE
|
|
186
|
+
? void 0
|
|
187
|
+
: `(${replaceTableName(condition, escapeId(tableName))})`,
|
|
188
|
+
extraCondition,
|
|
189
|
+
],
|
|
190
|
+
(condition2) => !isUndefined(condition2),
|
|
191
|
+
);
|
|
192
|
+
return isEmpty(conditions)
|
|
193
|
+
? EMPTY_STRING
|
|
194
|
+
: WHERE + arrayJoin(conditions, 'AND');
|
|
195
|
+
};
|
|
196
|
+
const replaceTableName = (condition, tableName) =>
|
|
197
|
+
strReplace(condition, TABLE_NAME_PLACEHOLDER_REGEX, tableName);
|
|
198
|
+
|
|
199
|
+
const collSize = (coll) => coll?.size ?? 0;
|
|
200
|
+
const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
|
|
201
|
+
const collIsEmpty = (coll) => isUndefined(coll) || collSize(coll) == 0;
|
|
202
|
+
const collValues = (coll) => [...(coll?.values() ?? [])];
|
|
203
|
+
const collClear = (coll) => coll.clear();
|
|
204
|
+
const collForEach = (coll, cb) => coll?.forEach(cb);
|
|
205
|
+
const collDel = (coll, keyOrValue) => coll?.delete(keyOrValue);
|
|
206
|
+
|
|
195
207
|
const jsonString = JSON.stringify;
|
|
196
208
|
const jsonParse = JSON.parse;
|
|
197
209
|
const jsonStringWithUndefined = (obj) =>
|
|
@@ -1039,7 +1051,7 @@ const getCommandFunctions = (
|
|
|
1039
1051
|
await executeCommand(
|
|
1040
1052
|
SELECT_STAR_FROM +
|
|
1041
1053
|
escapeId(tableName) +
|
|
1042
|
-
|
|
1054
|
+
getWhere(tableName, condition),
|
|
1043
1055
|
),
|
|
1044
1056
|
(row) => {
|
|
1045
1057
|
const rowId = row[rowIdColumnName];
|
|
@@ -1195,9 +1207,7 @@ const getCommandFunctions = (
|
|
|
1195
1207
|
if (isUndefined(content)) {
|
|
1196
1208
|
if (isUndefined(contentSubIdSet)) {
|
|
1197
1209
|
await executeCommand(
|
|
1198
|
-
DELETE_FROM +
|
|
1199
|
-
escapeId(tableName) +
|
|
1200
|
-
getWhereCondition(tableName, condition),
|
|
1210
|
+
DELETE_FROM + escapeId(tableName) + getWhere(tableName, condition),
|
|
1201
1211
|
);
|
|
1202
1212
|
}
|
|
1203
1213
|
} else {
|
|
@@ -1207,8 +1217,11 @@ const getCommandFunctions = (
|
|
|
1207
1217
|
await executeCommand(
|
|
1208
1218
|
DELETE_FROM +
|
|
1209
1219
|
escapeId(tableName) +
|
|
1210
|
-
|
|
1211
|
-
|
|
1220
|
+
getWhere(
|
|
1221
|
+
tableName,
|
|
1222
|
+
condition,
|
|
1223
|
+
`(${escapeId(rowIdColumnName)}=${getPlaceholder([1])})`,
|
|
1224
|
+
),
|
|
1212
1225
|
[rowId],
|
|
1213
1226
|
);
|
|
1214
1227
|
} else if (!isEmpty(settingColumnNames)) {
|
|
@@ -1267,8 +1280,12 @@ const getCommandFunctions = (
|
|
|
1267
1280
|
await executeCommand(
|
|
1268
1281
|
DELETE_FROM +
|
|
1269
1282
|
escapeId(tableName) +
|
|
1270
|
-
|
|
1271
|
-
|
|
1283
|
+
getWhere(
|
|
1284
|
+
tableName,
|
|
1285
|
+
condition,
|
|
1286
|
+
// eslint-disable-next-line max-len
|
|
1287
|
+
`${escapeId(rowIdColumnName)}NOT IN(${getPlaceholders(deleteRowIds, getPlaceholder)})`,
|
|
1288
|
+
),
|
|
1272
1289
|
deleteRowIds,
|
|
1273
1290
|
);
|
|
1274
1291
|
} else if (
|
|
@@ -1276,9 +1293,7 @@ const getCommandFunctions = (
|
|
|
1276
1293
|
collHas(schemaMap, tableName)
|
|
1277
1294
|
) {
|
|
1278
1295
|
await executeCommand(
|
|
1279
|
-
DELETE_FROM +
|
|
1280
|
-
escapeId(tableName) +
|
|
1281
|
-
getWhereCondition(tableName, condition),
|
|
1296
|
+
DELETE_FROM + escapeId(tableName) + getWhere(tableName, condition),
|
|
1282
1297
|
);
|
|
1283
1298
|
}
|
|
1284
1299
|
}
|
|
@@ -256,8 +256,20 @@ const getPlaceholders = (array, getPlaceholder, offset = [1]) =>
|
|
|
256
256
|
arrayMap(array, () => getPlaceholder(offset)),
|
|
257
257
|
COMMA,
|
|
258
258
|
);
|
|
259
|
-
const
|
|
260
|
-
|
|
259
|
+
const getWhere = (tableName, condition = TRUE, extraCondition) => {
|
|
260
|
+
const conditions = arrayFilter(
|
|
261
|
+
[
|
|
262
|
+
condition == TRUE
|
|
263
|
+
? void 0
|
|
264
|
+
: `(${replaceTableName(condition, escapeId(tableName))})`,
|
|
265
|
+
extraCondition,
|
|
266
|
+
],
|
|
267
|
+
(condition2) => !isUndefined(condition2),
|
|
268
|
+
);
|
|
269
|
+
return isEmpty(conditions)
|
|
270
|
+
? EMPTY_STRING
|
|
271
|
+
: WHERE + arrayJoin(conditions, 'AND');
|
|
272
|
+
};
|
|
261
273
|
const replaceTableName = (condition, tableName) =>
|
|
262
274
|
strReplace(condition, TABLE_NAME_PLACEHOLDER_REGEX, tableName);
|
|
263
275
|
|
|
@@ -1038,7 +1050,7 @@ const getCommandFunctions = (
|
|
|
1038
1050
|
await executeCommand(
|
|
1039
1051
|
SELECT_STAR_FROM +
|
|
1040
1052
|
escapeId(tableName) +
|
|
1041
|
-
|
|
1053
|
+
getWhere(tableName, condition),
|
|
1042
1054
|
),
|
|
1043
1055
|
(row) => {
|
|
1044
1056
|
const rowId = row[rowIdColumnName];
|
|
@@ -1194,9 +1206,7 @@ const getCommandFunctions = (
|
|
|
1194
1206
|
if (isUndefined(content)) {
|
|
1195
1207
|
if (isUndefined(contentSubIdSet)) {
|
|
1196
1208
|
await executeCommand(
|
|
1197
|
-
DELETE_FROM +
|
|
1198
|
-
escapeId(tableName) +
|
|
1199
|
-
getWhereCondition(tableName, condition),
|
|
1209
|
+
DELETE_FROM + escapeId(tableName) + getWhere(tableName, condition),
|
|
1200
1210
|
);
|
|
1201
1211
|
}
|
|
1202
1212
|
} else {
|
|
@@ -1206,8 +1216,11 @@ const getCommandFunctions = (
|
|
|
1206
1216
|
await executeCommand(
|
|
1207
1217
|
DELETE_FROM +
|
|
1208
1218
|
escapeId(tableName) +
|
|
1209
|
-
|
|
1210
|
-
|
|
1219
|
+
getWhere(
|
|
1220
|
+
tableName,
|
|
1221
|
+
condition,
|
|
1222
|
+
`(${escapeId(rowIdColumnName)}=${getPlaceholder([1])})`,
|
|
1223
|
+
),
|
|
1211
1224
|
[rowId],
|
|
1212
1225
|
);
|
|
1213
1226
|
} else if (!isEmpty(settingColumnNames)) {
|
|
@@ -1266,8 +1279,12 @@ const getCommandFunctions = (
|
|
|
1266
1279
|
await executeCommand(
|
|
1267
1280
|
DELETE_FROM +
|
|
1268
1281
|
escapeId(tableName) +
|
|
1269
|
-
|
|
1270
|
-
|
|
1282
|
+
getWhere(
|
|
1283
|
+
tableName,
|
|
1284
|
+
condition,
|
|
1285
|
+
// eslint-disable-next-line max-len
|
|
1286
|
+
`${escapeId(rowIdColumnName)}NOT IN(${getPlaceholders(deleteRowIds, getPlaceholder)})`,
|
|
1287
|
+
),
|
|
1271
1288
|
deleteRowIds,
|
|
1272
1289
|
);
|
|
1273
1290
|
} else if (
|
|
@@ -1275,9 +1292,7 @@ const getCommandFunctions = (
|
|
|
1275
1292
|
collHas(schemaMap, tableName)
|
|
1276
1293
|
) {
|
|
1277
1294
|
await executeCommand(
|
|
1278
|
-
DELETE_FROM +
|
|
1279
|
-
escapeId(tableName) +
|
|
1280
|
-
getWhereCondition(tableName, condition),
|
|
1295
|
+
DELETE_FROM + escapeId(tableName) + getWhere(tableName, condition),
|
|
1281
1296
|
);
|
|
1282
1297
|
}
|
|
1283
1298
|
}
|
|
@@ -256,8 +256,20 @@ const getPlaceholders = (array, getPlaceholder, offset = [1]) =>
|
|
|
256
256
|
arrayMap(array, () => getPlaceholder(offset)),
|
|
257
257
|
COMMA,
|
|
258
258
|
);
|
|
259
|
-
const
|
|
260
|
-
|
|
259
|
+
const getWhere = (tableName, condition = TRUE, extraCondition) => {
|
|
260
|
+
const conditions = arrayFilter(
|
|
261
|
+
[
|
|
262
|
+
condition == TRUE
|
|
263
|
+
? void 0
|
|
264
|
+
: `(${replaceTableName(condition, escapeId(tableName))})`,
|
|
265
|
+
extraCondition,
|
|
266
|
+
],
|
|
267
|
+
(condition2) => !isUndefined(condition2),
|
|
268
|
+
);
|
|
269
|
+
return isEmpty(conditions)
|
|
270
|
+
? EMPTY_STRING
|
|
271
|
+
: WHERE + arrayJoin(conditions, 'AND');
|
|
272
|
+
};
|
|
261
273
|
const replaceTableName = (condition, tableName) =>
|
|
262
274
|
strReplace(condition, TABLE_NAME_PLACEHOLDER_REGEX, tableName);
|
|
263
275
|
|
|
@@ -1038,7 +1050,7 @@ const getCommandFunctions = (
|
|
|
1038
1050
|
await executeCommand(
|
|
1039
1051
|
SELECT_STAR_FROM +
|
|
1040
1052
|
escapeId(tableName) +
|
|
1041
|
-
|
|
1053
|
+
getWhere(tableName, condition),
|
|
1042
1054
|
),
|
|
1043
1055
|
(row) => {
|
|
1044
1056
|
const rowId = row[rowIdColumnName];
|
|
@@ -1194,9 +1206,7 @@ const getCommandFunctions = (
|
|
|
1194
1206
|
if (isUndefined(content)) {
|
|
1195
1207
|
if (isUndefined(contentSubIdSet)) {
|
|
1196
1208
|
await executeCommand(
|
|
1197
|
-
DELETE_FROM +
|
|
1198
|
-
escapeId(tableName) +
|
|
1199
|
-
getWhereCondition(tableName, condition),
|
|
1209
|
+
DELETE_FROM + escapeId(tableName) + getWhere(tableName, condition),
|
|
1200
1210
|
);
|
|
1201
1211
|
}
|
|
1202
1212
|
} else {
|
|
@@ -1206,8 +1216,11 @@ const getCommandFunctions = (
|
|
|
1206
1216
|
await executeCommand(
|
|
1207
1217
|
DELETE_FROM +
|
|
1208
1218
|
escapeId(tableName) +
|
|
1209
|
-
|
|
1210
|
-
|
|
1219
|
+
getWhere(
|
|
1220
|
+
tableName,
|
|
1221
|
+
condition,
|
|
1222
|
+
`(${escapeId(rowIdColumnName)}=${getPlaceholder([1])})`,
|
|
1223
|
+
),
|
|
1211
1224
|
[rowId],
|
|
1212
1225
|
);
|
|
1213
1226
|
} else if (!isEmpty(settingColumnNames)) {
|
|
@@ -1266,8 +1279,12 @@ const getCommandFunctions = (
|
|
|
1266
1279
|
await executeCommand(
|
|
1267
1280
|
DELETE_FROM +
|
|
1268
1281
|
escapeId(tableName) +
|
|
1269
|
-
|
|
1270
|
-
|
|
1282
|
+
getWhere(
|
|
1283
|
+
tableName,
|
|
1284
|
+
condition,
|
|
1285
|
+
// eslint-disable-next-line max-len
|
|
1286
|
+
`${escapeId(rowIdColumnName)}NOT IN(${getPlaceholders(deleteRowIds, getPlaceholder)})`,
|
|
1287
|
+
),
|
|
1271
1288
|
deleteRowIds,
|
|
1272
1289
|
);
|
|
1273
1290
|
} else if (
|
|
@@ -1275,9 +1292,7 @@ const getCommandFunctions = (
|
|
|
1275
1292
|
collHas(schemaMap, tableName)
|
|
1276
1293
|
) {
|
|
1277
1294
|
await executeCommand(
|
|
1278
|
-
DELETE_FROM +
|
|
1279
|
-
escapeId(tableName) +
|
|
1280
|
-
getWhereCondition(tableName, condition),
|
|
1295
|
+
DELETE_FROM + escapeId(tableName) + getWhere(tableName, condition),
|
|
1281
1296
|
);
|
|
1282
1297
|
}
|
|
1283
1298
|
}
|
|
@@ -255,8 +255,20 @@ const getPlaceholders = (array, getPlaceholder, offset = [1]) =>
|
|
|
255
255
|
arrayMap(array, () => getPlaceholder(offset)),
|
|
256
256
|
COMMA,
|
|
257
257
|
);
|
|
258
|
-
const
|
|
259
|
-
|
|
258
|
+
const getWhere = (tableName, condition = TRUE, extraCondition) => {
|
|
259
|
+
const conditions = arrayFilter(
|
|
260
|
+
[
|
|
261
|
+
condition == TRUE
|
|
262
|
+
? void 0
|
|
263
|
+
: `(${replaceTableName(condition, escapeId(tableName))})`,
|
|
264
|
+
extraCondition,
|
|
265
|
+
],
|
|
266
|
+
(condition2) => !isUndefined(condition2),
|
|
267
|
+
);
|
|
268
|
+
return isEmpty(conditions)
|
|
269
|
+
? EMPTY_STRING
|
|
270
|
+
: WHERE + arrayJoin(conditions, 'AND');
|
|
271
|
+
};
|
|
260
272
|
const replaceTableName = (condition, tableName) =>
|
|
261
273
|
strReplace(condition, TABLE_NAME_PLACEHOLDER_REGEX, tableName);
|
|
262
274
|
|
|
@@ -1037,7 +1049,7 @@ const getCommandFunctions = (
|
|
|
1037
1049
|
await executeCommand(
|
|
1038
1050
|
SELECT_STAR_FROM +
|
|
1039
1051
|
escapeId(tableName) +
|
|
1040
|
-
|
|
1052
|
+
getWhere(tableName, condition),
|
|
1041
1053
|
),
|
|
1042
1054
|
(row) => {
|
|
1043
1055
|
const rowId = row[rowIdColumnName];
|
|
@@ -1193,9 +1205,7 @@ const getCommandFunctions = (
|
|
|
1193
1205
|
if (isUndefined(content)) {
|
|
1194
1206
|
if (isUndefined(contentSubIdSet)) {
|
|
1195
1207
|
await executeCommand(
|
|
1196
|
-
DELETE_FROM +
|
|
1197
|
-
escapeId(tableName) +
|
|
1198
|
-
getWhereCondition(tableName, condition),
|
|
1208
|
+
DELETE_FROM + escapeId(tableName) + getWhere(tableName, condition),
|
|
1199
1209
|
);
|
|
1200
1210
|
}
|
|
1201
1211
|
} else {
|
|
@@ -1205,8 +1215,11 @@ const getCommandFunctions = (
|
|
|
1205
1215
|
await executeCommand(
|
|
1206
1216
|
DELETE_FROM +
|
|
1207
1217
|
escapeId(tableName) +
|
|
1208
|
-
|
|
1209
|
-
|
|
1218
|
+
getWhere(
|
|
1219
|
+
tableName,
|
|
1220
|
+
condition,
|
|
1221
|
+
`(${escapeId(rowIdColumnName)}=${getPlaceholder([1])})`,
|
|
1222
|
+
),
|
|
1210
1223
|
[rowId],
|
|
1211
1224
|
);
|
|
1212
1225
|
} else if (!isEmpty(settingColumnNames)) {
|
|
@@ -1265,8 +1278,12 @@ const getCommandFunctions = (
|
|
|
1265
1278
|
await executeCommand(
|
|
1266
1279
|
DELETE_FROM +
|
|
1267
1280
|
escapeId(tableName) +
|
|
1268
|
-
|
|
1269
|
-
|
|
1281
|
+
getWhere(
|
|
1282
|
+
tableName,
|
|
1283
|
+
condition,
|
|
1284
|
+
// eslint-disable-next-line max-len
|
|
1285
|
+
`${escapeId(rowIdColumnName)}NOT IN(${getPlaceholders(deleteRowIds, getPlaceholder)})`,
|
|
1286
|
+
),
|
|
1270
1287
|
deleteRowIds,
|
|
1271
1288
|
);
|
|
1272
1289
|
} else if (
|
|
@@ -1274,9 +1291,7 @@ const getCommandFunctions = (
|
|
|
1274
1291
|
collHas(schemaMap, tableName)
|
|
1275
1292
|
) {
|
|
1276
1293
|
await executeCommand(
|
|
1277
|
-
DELETE_FROM +
|
|
1278
|
-
escapeId(tableName) +
|
|
1279
|
-
getWhereCondition(tableName, condition),
|
|
1294
|
+
DELETE_FROM + escapeId(tableName) + getWhere(tableName, condition),
|
|
1280
1295
|
);
|
|
1281
1296
|
}
|
|
1282
1297
|
}
|
|
@@ -255,8 +255,20 @@ const getPlaceholders = (array, getPlaceholder, offset = [1]) =>
|
|
|
255
255
|
arrayMap(array, () => getPlaceholder(offset)),
|
|
256
256
|
COMMA,
|
|
257
257
|
);
|
|
258
|
-
const
|
|
259
|
-
|
|
258
|
+
const getWhere = (tableName, condition = TRUE, extraCondition) => {
|
|
259
|
+
const conditions = arrayFilter(
|
|
260
|
+
[
|
|
261
|
+
condition == TRUE
|
|
262
|
+
? void 0
|
|
263
|
+
: `(${replaceTableName(condition, escapeId(tableName))})`,
|
|
264
|
+
extraCondition,
|
|
265
|
+
],
|
|
266
|
+
(condition2) => !isUndefined(condition2),
|
|
267
|
+
);
|
|
268
|
+
return isEmpty(conditions)
|
|
269
|
+
? EMPTY_STRING
|
|
270
|
+
: WHERE + arrayJoin(conditions, 'AND');
|
|
271
|
+
};
|
|
260
272
|
const replaceTableName = (condition, tableName) =>
|
|
261
273
|
strReplace(condition, TABLE_NAME_PLACEHOLDER_REGEX, tableName);
|
|
262
274
|
|
|
@@ -1037,7 +1049,7 @@ const getCommandFunctions = (
|
|
|
1037
1049
|
await executeCommand(
|
|
1038
1050
|
SELECT_STAR_FROM +
|
|
1039
1051
|
escapeId(tableName) +
|
|
1040
|
-
|
|
1052
|
+
getWhere(tableName, condition),
|
|
1041
1053
|
),
|
|
1042
1054
|
(row) => {
|
|
1043
1055
|
const rowId = row[rowIdColumnName];
|
|
@@ -1193,9 +1205,7 @@ const getCommandFunctions = (
|
|
|
1193
1205
|
if (isUndefined(content)) {
|
|
1194
1206
|
if (isUndefined(contentSubIdSet)) {
|
|
1195
1207
|
await executeCommand(
|
|
1196
|
-
DELETE_FROM +
|
|
1197
|
-
escapeId(tableName) +
|
|
1198
|
-
getWhereCondition(tableName, condition),
|
|
1208
|
+
DELETE_FROM + escapeId(tableName) + getWhere(tableName, condition),
|
|
1199
1209
|
);
|
|
1200
1210
|
}
|
|
1201
1211
|
} else {
|
|
@@ -1205,8 +1215,11 @@ const getCommandFunctions = (
|
|
|
1205
1215
|
await executeCommand(
|
|
1206
1216
|
DELETE_FROM +
|
|
1207
1217
|
escapeId(tableName) +
|
|
1208
|
-
|
|
1209
|
-
|
|
1218
|
+
getWhere(
|
|
1219
|
+
tableName,
|
|
1220
|
+
condition,
|
|
1221
|
+
`(${escapeId(rowIdColumnName)}=${getPlaceholder([1])})`,
|
|
1222
|
+
),
|
|
1210
1223
|
[rowId],
|
|
1211
1224
|
);
|
|
1212
1225
|
} else if (!isEmpty(settingColumnNames)) {
|
|
@@ -1265,8 +1278,12 @@ const getCommandFunctions = (
|
|
|
1265
1278
|
await executeCommand(
|
|
1266
1279
|
DELETE_FROM +
|
|
1267
1280
|
escapeId(tableName) +
|
|
1268
|
-
|
|
1269
|
-
|
|
1281
|
+
getWhere(
|
|
1282
|
+
tableName,
|
|
1283
|
+
condition,
|
|
1284
|
+
// eslint-disable-next-line max-len
|
|
1285
|
+
`${escapeId(rowIdColumnName)}NOT IN(${getPlaceholders(deleteRowIds, getPlaceholder)})`,
|
|
1286
|
+
),
|
|
1270
1287
|
deleteRowIds,
|
|
1271
1288
|
);
|
|
1272
1289
|
} else if (
|
|
@@ -1274,9 +1291,7 @@ const getCommandFunctions = (
|
|
|
1274
1291
|
collHas(schemaMap, tableName)
|
|
1275
1292
|
) {
|
|
1276
1293
|
await executeCommand(
|
|
1277
|
-
DELETE_FROM +
|
|
1278
|
-
escapeId(tableName) +
|
|
1279
|
-
getWhereCondition(tableName, condition),
|
|
1294
|
+
DELETE_FROM + escapeId(tableName) + getWhere(tableName, condition),
|
|
1280
1295
|
);
|
|
1281
1296
|
}
|
|
1282
1297
|
}
|