readonly sessions on mongo (+checks on BE)

This commit is contained in:
Jan Prochazka
2022-03-17 13:17:30 +01:00
parent 7d196c7c62
commit 8f1d76fd2a
8 changed files with 51 additions and 13 deletions

View File

@@ -159,7 +159,7 @@ module.exports = {
async collectionData({ conid, database, options }) {
const opened = await this.ensureOpened(conid, database);
const res = await this.sendRequest(opened, { msgtype: 'collectionData', options });
return res.result;
return res.result || null;
},
async loadDataCore(msgtype, { conid, database, ...args }) {
@@ -167,6 +167,10 @@ module.exports = {
const res = await this.sendRequest(opened, { msgtype, ...args });
if (res.errorMessage) {
console.error(res.errorMessage);
return {
errorMessage: res.errorMessage,
};
}
return res.result || null;
},
@@ -193,19 +197,26 @@ module.exports = {
callMethod_meta: true,
async callMethod({ conid, database, method, args }) {
const opened = await this.ensureOpened(conid, database);
const res = await this.sendRequest(opened, { msgtype: 'callMethod', method, args });
if (res.errorMessage) {
console.error(res.errorMessage);
}
return res.result || null;
return this.loadDataCore('callMethod', { conid, database, method, args });
// const opened = await this.ensureOpened(conid, database);
// const res = await this.sendRequest(opened, { msgtype: 'callMethod', method, args });
// if (res.errorMessage) {
// console.error(res.errorMessage);
// }
// return res.result || null;
},
updateCollection_meta: true,
async updateCollection({ conid, database, changeSet }) {
const opened = await this.ensureOpened(conid, database);
const res = await this.sendRequest(opened, { msgtype: 'updateCollection', changeSet });
return res.result;
if (res.errorMessage) {
return {
errorMessage: res.errorMessage,
};
}
return res.result || null;
},
status_meta: true,