1
0
Fork 0
mirror of synced 2024-07-09 00:06:05 +12:00

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

View file

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

File diff suppressed because it is too large Load diff