Removing use of db.post as its dangerous to allow the possibility of _id being auto-generated, these docs would be lost as we couldn't query them out by the usual id mechanism.

This commit is contained in:
mike12345567 2021-09-21 16:07:04 +01:00
parent c8dbf02acf
commit e8e331e578
6 changed files with 6 additions and 7 deletions

View File

@ -104,7 +104,7 @@ describe("third party common", () => {
_id: id, _id: id,
email: email, email: email,
} }
const response = await db.post(dbUser) const response = await db.put(dbUser)
dbUser._rev = response.rev dbUser._rev = response.rev
} }

View File

@ -71,7 +71,7 @@ exports.authenticateThirdParty = async function (
dbUser = await syncUser(dbUser, thirdPartyUser) dbUser = await syncUser(dbUser, thirdPartyUser)
// create or sync the user // create or sync the user
const response = await db.post(dbUser) const response = await db.put(dbUser)
dbUser._rev = response.rev dbUser._rev = response.rev
// authenticate // authenticate

View File

@ -51,7 +51,7 @@ exports.buildSchemaFromDb = async function (ctx) {
await connector.buildSchema(datasource._id, datasource.entities) await connector.buildSchema(datasource._id, datasource.entities)
datasource.entities = connector.tables datasource.entities = connector.tables
const response = await db.post(datasource) const response = await db.put(datasource)
datasource._rev = response.rev datasource._rev = response.rev
ctx.body = datasource ctx.body = datasource
@ -89,7 +89,7 @@ exports.save = async function (ctx) {
...ctx.request.body, ...ctx.request.body,
} }
const response = await db.post(datasource) const response = await db.put(datasource)
datasource._rev = response.rev datasource._rev = response.rev
// Drain connection pools when configuration is changed // Drain connection pools when configuration is changed

View File

@ -197,7 +197,6 @@ exports.fetchView = async ctx => {
throw "View does not exist." throw "View does not exist."
} }
let response let response
// TODO: make sure not self hosted in Cloud
if (env.SELF_HOSTED) { if (env.SELF_HOSTED) {
response = await db.query(`database/${viewName}`, { response = await db.query(`database/${viewName}`, {
include_docs: !calculation, include_docs: !calculation,

View File

@ -145,7 +145,7 @@ exports.save = async function (ctx) {
if (updatedRows && updatedRows.length !== 0) { if (updatedRows && updatedRows.length !== 0) {
await db.bulkDocs(updatedRows) await db.bulkDocs(updatedRows)
} }
const result = await db.post(tableToSave) const result = await db.put(tableToSave)
tableToSave._rev = result.rev tableToSave._rev = result.rev
tableToSave = await tableSaveFunctions.after(tableToSave) tableToSave = await tableSaveFunctions.after(tableToSave)

View File

@ -11,7 +11,7 @@ exports.save = async function (ctx) {
} }
try { try {
const response = await db.post(workspaceDoc) const response = await db.put(workspaceDoc)
ctx.body = { ctx.body = {
_id: response.id, _id: response.id,
_rev: response.rev, _rev: response.rev,