making HTTP POST and PUT readable, more robust app import to avoid document conflicts

This commit is contained in:
Martin McKeaveney 2021-05-29 13:52:31 +01:00
parent ad3e7d9b9a
commit 03a9af0369
3 changed files with 22 additions and 1305 deletions

View File

@ -101,6 +101,7 @@ async function createInstance(template) {
if (!ok) {
throw "Error loading database dump from template."
}
var { _rev } = await db.get(DocumentTypes.APP_METADATA)
} else {
// create the users table
await db.put(USERS_TABLE_SCHEMA)
@ -111,7 +112,7 @@ async function createInstance(template) {
await createRoutingView(appId)
await createAllSearchIndex(appId)
return { _id: appId }
return { _id: appId, _rev }
}
exports.fetch = async function (ctx) {
@ -197,6 +198,9 @@ exports.create = async function (ctx) {
type: "cloud",
},
}
if (instance._rev) {
newApplication._rev = instance._rev
}
const instanceDb = new CouchDB(appId)
await instanceDb.put(newApplication)

View File

@ -20,6 +20,7 @@ const SCHEMA = {
},
query: {
create: {
readable: true,
displayName: "POST",
type: QUERY_TYPES.FIELDS,
urlDisplay: true,
@ -40,6 +41,7 @@ const SCHEMA = {
},
read: {
displayName: "GET",
readable: true,
type: QUERY_TYPES.FIELDS,
urlDisplay: true,
fields: {
@ -56,6 +58,7 @@ const SCHEMA = {
},
update: {
displayName: "PUT",
readable: true,
type: QUERY_TYPES.FIELDS,
urlDisplay: true,
fields: {

File diff suppressed because it is too large Load Diff