@aws-amplify/datastore-storage-adapter 1.3.9-next.13 → 1.3.9-next.32
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/CHANGELOG.md +48 -0
- package/lib/ExpoSQLiteAdapter/ExpoSQLiteAdapter.js +2 -4
- package/lib/ExpoSQLiteAdapter/ExpoSQLiteAdapter.js.map +1 -1
- package/lib/ExpoSQLiteAdapter/ExpoSQLiteDatabase.js +25 -80
- package/lib/ExpoSQLiteAdapter/ExpoSQLiteDatabase.js.map +1 -1
- package/lib/SQLiteAdapter/SQLiteAdapter.js +2 -4
- package/lib/SQLiteAdapter/SQLiteAdapter.js.map +1 -1
- package/lib/SQLiteAdapter/SQLiteDatabase.js +34 -99
- package/lib/SQLiteAdapter/SQLiteDatabase.js.map +1 -1
- package/lib/common/CommonSQLiteAdapter.js +36 -105
- package/lib/common/CommonSQLiteAdapter.js.map +1 -1
- package/lib/common/SQLiteUtils.js +28 -55
- package/lib/common/SQLiteUtils.js.map +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib-esm/ExpoSQLiteAdapter/ExpoSQLiteDatabase.js +1 -56
- package/lib-esm/ExpoSQLiteAdapter/ExpoSQLiteDatabase.js.map +1 -1
- package/lib-esm/SQLiteAdapter/SQLiteDatabase.js +1 -63
- package/lib-esm/SQLiteAdapter/SQLiteDatabase.js.map +1 -1
- package/lib-esm/common/CommonSQLiteAdapter.d.ts +3 -3
- package/lib-esm/common/CommonSQLiteAdapter.js +1 -70
- package/lib-esm/common/CommonSQLiteAdapter.js.map +1 -1
- package/lib-esm/common/SQLiteUtils.js +14 -41
- package/lib-esm/common/SQLiteUtils.js.map +1 -1
- package/lib-esm/common/types.d.ts +4 -1
- package/package.json +17 -5
- package/src/common/CommonSQLiteAdapter.ts +6 -3
- package/src/common/SQLiteUtils.ts +16 -10
- package/src/common/types.ts +6 -1
- package/build.js +0 -5
- package/dist/aws-amplify-datastore-sqlite-adapter-expo.js +0 -2506
- package/dist/aws-amplify-datastore-sqlite-adapter-expo.js.map +0 -1
- package/dist/aws-amplify-datastore-sqlite-adapter-expo.min.js +0 -2
- package/dist/aws-amplify-datastore-sqlite-adapter-expo.min.js.map +0 -1
- package/dist/aws-amplify-datastore-storage-adapter.js +0 -2460
- package/dist/aws-amplify-datastore-storage-adapter.js.map +0 -1
- package/dist/aws-amplify-datastore-storage-adapter.min.js +0 -2
- package/dist/aws-amplify-datastore-storage-adapter.min.js.map +0 -1
- package/index.js +0 -7
- package/lib/ExpoSQLiteAdapter/ExpoSQLiteAdapter.d.ts +0 -3
- package/lib/ExpoSQLiteAdapter/ExpoSQLiteDatabase.d.ts +0 -17
- package/lib/SQLiteAdapter/SQLiteAdapter.d.ts +0 -3
- package/lib/SQLiteAdapter/SQLiteDatabase.d.ts +0 -17
- package/lib/common/CommonSQLiteAdapter.d.ts +0 -23
- package/lib/common/SQLiteUtils.d.ts +0 -16
- package/lib/common/constants.d.ts +0 -1
- package/lib/common/types.d.ts +0 -13
- package/lib/index.d.ts +0 -2
- package/webpack.config.dev.js +0 -8
|
@@ -148,7 +148,7 @@ export function modelCreateTableStatement(
|
|
|
148
148
|
let fields = Object.values(model.fields).reduce((acc, field: ModelField) => {
|
|
149
149
|
if (isGraphQLScalarType(field.type)) {
|
|
150
150
|
if (field.name === 'id') {
|
|
151
|
-
return acc
|
|
151
|
+
return [...acc, '"id" PRIMARY KEY NOT NULL'];
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
let columnParam = `"${field.name}" ${getSQLiteType(field.type)}`;
|
|
@@ -157,7 +157,7 @@ export function modelCreateTableStatement(
|
|
|
157
157
|
columnParam += ' NOT NULL';
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
return acc
|
|
160
|
+
return [...acc, `${columnParam}`];
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
if (isModelFieldType(field.type)) {
|
|
@@ -167,7 +167,7 @@ export function modelCreateTableStatement(
|
|
|
167
167
|
if (isTargetNameAssociation(field.association)) {
|
|
168
168
|
// check if this field has been explicitly defined in the model
|
|
169
169
|
const fkDefinedInModel = Object.values(model.fields).find(
|
|
170
|
-
(f: ModelField) => f.name === field
|
|
170
|
+
(f: ModelField) => f.name === field?.association?.targetName
|
|
171
171
|
);
|
|
172
172
|
|
|
173
173
|
// if the FK is not explicitly defined in the model, we have to add it here
|
|
@@ -179,7 +179,7 @@ export function modelCreateTableStatement(
|
|
|
179
179
|
|
|
180
180
|
// ignore isRequired param for model fields, since they will not contain
|
|
181
181
|
// the related data locally
|
|
182
|
-
return acc
|
|
182
|
+
return [...acc, `${columnParam}`];
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
// default to TEXT
|
|
@@ -189,19 +189,25 @@ export function modelCreateTableStatement(
|
|
|
189
189
|
columnParam += ' NOT NULL';
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
return acc
|
|
193
|
-
},
|
|
192
|
+
return [...acc, `${columnParam}`];
|
|
193
|
+
}, [] as string[]);
|
|
194
194
|
|
|
195
195
|
implicitAuthFields.forEach((authField: string) => {
|
|
196
|
-
fields
|
|
196
|
+
fields.push(`${authField} TEXT`);
|
|
197
197
|
});
|
|
198
198
|
|
|
199
199
|
if (userModel) {
|
|
200
|
-
fields
|
|
201
|
-
|
|
200
|
+
fields = [
|
|
201
|
+
...fields,
|
|
202
|
+
`"_version" INTEGER`,
|
|
203
|
+
`"_lastChangedAt" INTEGER`,
|
|
204
|
+
`"_deleted" INTEGER`,
|
|
205
|
+
];
|
|
202
206
|
}
|
|
203
207
|
|
|
204
|
-
const createTableStatement = `CREATE TABLE IF NOT EXISTS "${
|
|
208
|
+
const createTableStatement = `CREATE TABLE IF NOT EXISTS "${
|
|
209
|
+
model.name
|
|
210
|
+
}" (${fields.join(', ')});`;
|
|
205
211
|
return createTableStatement;
|
|
206
212
|
}
|
|
207
213
|
|
package/src/common/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PersistentModel } from '@aws-amplify/datastore';
|
|
1
|
+
import { PersistentModel, ModelInstanceMetadata } from '@aws-amplify/datastore';
|
|
2
2
|
|
|
3
3
|
export interface CommonSQLiteDatabase {
|
|
4
4
|
init(): Promise<void>;
|
|
@@ -27,3 +27,8 @@ export interface CommonSQLiteDatabase {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export type ParameterizedStatement = [string, any[]];
|
|
30
|
+
|
|
31
|
+
// TODO: remove once we implement CPK for this adapter
|
|
32
|
+
export type ModelInstanceMetadataWithId = ModelInstanceMetadata & {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|