Update PostgresStorageAdapter.js (#3578)
* Update PostgresStorageAdapter.js proper database API, via transaction. * Update PostgresStorageAdapter.js fixing bracket. * Update PostgresStorageAdapter.js adding the same rejection approach as before, the functionality remains identical. * Update PostgresStorageAdapter.js * Update PostgresStorageAdapter.js lint fixing * Update PostgresStorageAdapter.js fixing misspelling.
This commit is contained in:
committed by
Arthur Cinader
parent
5c5ef0313b
commit
271608bc82
@@ -1160,41 +1160,35 @@ export class PostgresStorageAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
performInitialization({ VolatileClassesSchemas }) {
|
performInitialization({ VolatileClassesSchemas }) {
|
||||||
const now = new Date().getTime();
|
|
||||||
debug('performInitialization');
|
debug('performInitialization');
|
||||||
let promises = VolatileClassesSchemas.map((schema) => {
|
const promises = VolatileClassesSchemas.map((schema) => {
|
||||||
return this.createTable(schema.className, schema).catch((err) =>{
|
return this.createTable(schema.className, schema).catch((err) => {
|
||||||
if (err.code === PostgresDuplicateRelationError || err.code === Parse.Error.INVALID_CLASS_NAME) {
|
if (err.code === PostgresDuplicateRelationError || err.code === Parse.Error.INVALID_CLASS_NAME) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
/* eslint-disable no-console */
|
return Promise.all(promises)
|
||||||
promises = promises.concat([
|
.then(() => {
|
||||||
this._client.none(sql.misc.jsonObjectSetKeys).catch((err) => {
|
return this._client.tx(t => {
|
||||||
console.error(err);
|
return t.batch([
|
||||||
}),
|
t.none(sql.misc.jsonObjectSetKeys),
|
||||||
this._client.none(sql.array.add).catch((err) => {
|
t.none(sql.array.add),
|
||||||
console.error(err);
|
t.none(sql.array.addUnique),
|
||||||
}),
|
t.none(sql.array.remove),
|
||||||
this._client.none(sql.array.addUnique).catch((err) => {
|
t.none(sql.array.containsAll),
|
||||||
console.error(err);
|
t.none(sql.array.contains)
|
||||||
}),
|
]);
|
||||||
this._client.none(sql.array.remove).catch((err) => {
|
});
|
||||||
console.error(err);
|
|
||||||
}),
|
|
||||||
this._client.none(sql.array.containsAll).catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
}),
|
|
||||||
this._client.none(sql.array.contains).catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
})
|
})
|
||||||
]);
|
.then(data => {
|
||||||
/* eslint-enable no-console */
|
debug(`initializationDone in ${data.duration}`);
|
||||||
return Promise.all(promises).then(() => {
|
})
|
||||||
debug(`initialzationDone in ${new Date().getTime() - now}`);
|
.catch(error => {
|
||||||
}, () => {});
|
/* eslint-disable no-console */
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user