Skip to content

Commit

Permalink
Allow the app DB tables to have an autoincrement column
Browse files Browse the repository at this point in the history
  • Loading branch information
yazz committed Dec 27, 2023
1 parent 33ac97e commit 2d14911
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ use_db("todo")
mm.oldDatabaseDefn.push(
{
name: "Add table TABLE_1",
up: ["create TABLE TABLE_1 ( id TEXT );"]
up: ["create TABLE TABLE_1 ( id INTEGER PRIMARY KEY AUTOINCREMENT);"]
})

changed = true
Expand Down Expand Up @@ -659,7 +659,7 @@ use_db("todo")
mm.oldDatabaseDefn.push(
{
name: "Add table " + newTableName,
up: ["create TABLE " + newTableName + "( id TEXT );"]
up: ["create TABLE " + newTableName + "( id INTEGER PRIMARY KEY AUTOINCREMENT );"]
})


Expand Down Expand Up @@ -756,7 +756,7 @@ use_db("todo")
let codeId = await mm.getCurrentCommitId()
let baseComponentId = yz.helpers.getValueOfCodeString(mm.text,"base_component_id")
await sqlRx(codeId, baseComponentId,
"insert into " + mm.pane_home_selectedTable + " (id,name) values (1,?)",
"insert into " + mm.pane_home_selectedTable + " (name) values (?)",
"Get the milk")
mm.data_rows = await sqlRx(codeId, baseComponentId, "select * from " + mm.pane_home_selectedTable)
//mm.data_rows = sql("select id,name from items")
Expand Down
4 changes: 2 additions & 2 deletions public/visifile_drivers/apps/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Yazz.component({
return
}

sql("insert into items (id,name) values (" + new Date().getTime() + " ,'" + x + "')")
sql("insert into items (name) values (?)", x)
this.items = sql("select id,name from items")
this.new_item = ""
}
Expand All @@ -76,7 +76,7 @@ Yazz.component({
{
name: "Create the initial item table"
,
up: ["CREATE TABLE items (id TEXT, name TEXT);",
up: ["CREATE TABLE items (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT);",
"alter TABLE items add column time INTEGER;"]
}
,
Expand Down

0 comments on commit 2d14911

Please sign in to comment.