|
|
|
@ -441,8 +441,8 @@ export class ApiService {
|
|
|
|
|
for ( const rec of data.databaseEntries ) {
|
|
|
|
|
const entry = new DatabaseEntry(
|
|
|
|
|
rec.DatabaseId,
|
|
|
|
|
JSON.stringify(rec.RowData || {}),
|
|
|
|
|
rec.UUID
|
|
|
|
|
rec.UUID,
|
|
|
|
|
JSON.stringify(rec.RowData || {})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await entry.save();
|
|
|
|
@ -812,6 +812,9 @@ export class ApiService {
|
|
|
|
|
|
|
|
|
|
this.get(`/db/${PageId}/${NodeId}/get/${DatabaseId}/data`).subscribe({
|
|
|
|
|
next: async result => {
|
|
|
|
|
// Resolve first so the GUI doesn't need to wait for the DB to sync to render
|
|
|
|
|
res(result.data);
|
|
|
|
|
|
|
|
|
|
for ( const row of result.data ) {
|
|
|
|
|
const existingDatabaseEntry = await this.db.databaseEntries.where({
|
|
|
|
|
DatabaseId, UUID: row.UUID,
|
|
|
|
@ -823,15 +826,13 @@ export class ApiService {
|
|
|
|
|
} else {
|
|
|
|
|
const newDatabaseEntry = new DatabaseEntry(
|
|
|
|
|
row.DatabaseId,
|
|
|
|
|
JSON.stringify(row.RowData),
|
|
|
|
|
row.UUID
|
|
|
|
|
row.UUID,
|
|
|
|
|
JSON.stringify(row.RowData)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await newDatabaseEntry.save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res(result.data);
|
|
|
|
|
},
|
|
|
|
|
error: rej,
|
|
|
|
|
});
|
|
|
|
@ -849,6 +850,9 @@ export class ApiService {
|
|
|
|
|
// If online, fetch the columns and sync the local database
|
|
|
|
|
this.get(`/db/${PageId}/${NodeId}/get/${DatabaseId}/columns`).subscribe({
|
|
|
|
|
next: async results => {
|
|
|
|
|
// Resolve this first, so the UI doesn't need to wait for the db sync to render
|
|
|
|
|
res(results.data);
|
|
|
|
|
|
|
|
|
|
for ( const def of results.data ) {
|
|
|
|
|
const existingColumnDef = await this.db.databaseColumns.where({
|
|
|
|
|
DatabaseId, UUID: def.UUID,
|
|
|
|
@ -870,8 +874,6 @@ export class ApiService {
|
|
|
|
|
await newColumnDef.save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res(results.data);
|
|
|
|
|
},
|
|
|
|
|
error: rej,
|
|
|
|
|
});
|
|
|
|
@ -968,8 +970,8 @@ export class ApiService {
|
|
|
|
|
for ( const row of rowData ) {
|
|
|
|
|
const newDatabaseEntry = new DatabaseEntry(
|
|
|
|
|
DatabaseId,
|
|
|
|
|
JSON.stringify(row),
|
|
|
|
|
DatabaseEntry.getUUID(),
|
|
|
|
|
JSON.stringify(row),
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -987,8 +989,8 @@ export class ApiService {
|
|
|
|
|
for ( const row of result.data ) {
|
|
|
|
|
const newDatabaseEntry = new DatabaseEntry(
|
|
|
|
|
row.DatabaseId,
|
|
|
|
|
JSON.stringify(row.RowData),
|
|
|
|
|
row.UUID
|
|
|
|
|
row.UUID,
|
|
|
|
|
JSON.stringify(row.RowData)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await newDatabaseEntry.save();
|
|
|
|
|