@live-change/framework
Advanced tools
Comparing version 0.2.8 to 0.2.9
const ModelDefinition = require("./ModelDefinition.js") | ||
const ForeignModelDefinition = require("./ForeignModelDefinition.js") | ||
const ActionDefinition = require("./ActionDefinition.js") | ||
const TriggerDefinition = require("./TriggerDefinition.js") | ||
const ViewDefinition = require("./ViewDefinition.js") | ||
@@ -77,3 +78,3 @@ const EventDefinition = require("./EventDefinition.js") | ||
trigger(definition) { | ||
const trigger = new ViewDefinition(definition) | ||
const trigger = new TriggerDefinition(definition) | ||
this.triggers[trigger.name] = trigger | ||
@@ -80,0 +81,0 @@ return trigger |
@@ -94,3 +94,3 @@ const utils = require("../utils.js") | ||
async execute(props) { | ||
await modelRuntime().create({...props.data, id: props.draft}, { conflict: 'replace' }) | ||
await modelRuntime().create({...props.data, id: props.draft}) | ||
} | ||
@@ -217,3 +217,14 @@ }) | ||
async execute(props) { | ||
await modelRuntime().create({...props.data, id: props.draft, draftStep: props.draftStep}, { conflict: 'update' }) | ||
await app.dao.request(['database', 'query', app.databaseName, `(${ | ||
async (input, output, { table, id, data, draftStep }) => { | ||
const value = await input.table(table).object(id).get() | ||
if(!value) { | ||
return await output.table(table).put({ ...data, id, draftStep }) | ||
} else { | ||
return await output.table(table).update(id, [ | ||
{ op:'merge', property: null, value: { ...data, draftStep} } | ||
]) | ||
} | ||
} | ||
})`, { table: modelRuntime().tableName, id: props.draft, data: props.data, draftStep: props.draftStep }]) | ||
} | ||
@@ -261,3 +272,15 @@ }) | ||
async execute(props) { | ||
await modelRuntime().create({...props.data, id: props.draft, draftStep: props.draftStep}, { conflict: 'update' }) | ||
await app.dao.request(['database', 'query', app.databaseName,`(${ | ||
async (input, output, { table, id, data, draftStep }) => { | ||
const value = await input.table(table).object(id).get() | ||
if(!value) { | ||
return await output.table(table).put({ ...data, id, draftStep }) | ||
} else { | ||
return await output.table(table).update(id, [ | ||
{ op:'merge', property: null, value: { ...data, draftStep} } | ||
]) | ||
} | ||
} | ||
})`, { table: modelRuntime().tableName, id: props.draft, data: props.data, draftStep: props.draftStep }]) | ||
//await modelRuntime().create({...props.data, id: props.draft, draftStep: props.draftStep}, { conflict: 'update' }) | ||
} | ||
@@ -264,0 +287,0 @@ }) |
{ | ||
"name": "@live-change/framework", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"description": "Live Change Framework - ultimate solution for real time mobile/web apps", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103230
2866