Compare commits

...

2 Commits

2 changed files with 13 additions and 3 deletions

View File

@@ -45,8 +45,7 @@ export default function CouchDocument(id, model, rev, markDeleted) {
"category": "domain object", "category": "domain object",
"type": model.type, "type": model.type,
"owner": "admin", "owner": "admin",
"name": model.name, "name": model.name
"created": Date.now()
}, },
"model": model "model": model
}; };

View File

@@ -377,8 +377,18 @@ class CouchObjectProvider {
}; };
return this.request(ALL_DOCS, 'POST', query, signal).then((response) => { return this.request(ALL_DOCS, 'POST', query, signal).then((response) => {
if (response && response.rows !== undefined) { if (!response) {
//There was no response - no error code, no rows, nothing - this is bad and should not happen
// Network error, CouchDB unreachable.
if (response === null) {
this.indicator.setIndicatorToState(DISCONNECTED);
}
console.error('Failed to retrieve response: #bulkGet');
} else if (response.rows !== undefined) {
return response.rows.reduce((map, row) => { return response.rows.reduce((map, row) => {
//row.doc === null if the document does not exist.
//row.doc === undefined if the document is not found.
if (row.doc !== undefined) { if (row.doc !== undefined) {
map[row.key] = this.#getModel(row.doc); map[row.key] = this.#getModel(row.doc);
} }
@@ -647,6 +657,7 @@ class CouchObjectProvider {
this.objectQueue[key].pending = true; this.objectQueue[key].pending = true;
const queued = this.objectQueue[key].dequeue(); const queued = this.objectQueue[key].dequeue();
let document = new CouchDocument(key, queued.model); let document = new CouchDocument(key, queued.model);
document.metadata.created = Date.now();
this.request(key, "PUT", document).then((response) => { this.request(key, "PUT", document).then((response) => {
console.log('create check response', key); console.log('create check response', key);
this.#checkResponse(response, queued.intermediateResponse, key); this.#checkResponse(response, queued.intermediateResponse, key);