1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00
This commit is contained in:
Martin McKeaveney 2020-06-25 22:43:10 +01:00
parent 63fc10e1e0
commit fb382329b8
2 changed files with 5 additions and 6 deletions

View file

@ -1,7 +1,6 @@
import { writable } from "svelte/store"
import { cloneDeep } from "lodash/fp"
import api from "../api"
import { update } from "lodash"
export const getBackendUiStore = () => {
const INITIAL_BACKEND_UI_STATE = {
@ -82,7 +81,7 @@ export const getBackendUiStore = () => {
}
const SAVE_MODEL_URL = `/api/models`
console.log(updatedModel);
console.log(updatedModel)
const response = await api.post(SAVE_MODEL_URL, updatedModel)
const savedModel = await response.json()
await store.actions.models.fetch()

View file

@ -24,12 +24,12 @@ exports.save = async function(ctx) {
...ctx.request.body,
}
// update renamed record fields when model is updated
// update renamed record fields when model is updated
const { _rename } = modelToSave
if (_rename) {
const records = await db.query(`database/all_${modelToSave._id}`, {
include_docs: true
});
include_docs: true,
})
const docs = records.rows.map(({ doc }) => {
doc[_rename.updated] = doc[_rename.old]
delete doc[_rename.old]
@ -55,7 +55,7 @@ exports.save = async function(ctx) {
modelId: modelToSave._id,
constraints: {
type: "array",
}
},
}
await db.put(linkedModel)
}