|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <title>jSQL test</title> |
| 6 | + </head> |
| 7 | + <body> |
| 8 | + <script src="../../jSQL.js"></script> |
| 9 | + <script> |
| 10 | + |
| 11 | + var data = [ |
| 12 | + [0, "rob", "hamburger"], |
| 13 | + [1, "bob", "fish tacos"], |
| 14 | + [2, "ted", "applesauce"] |
| 15 | + ]; |
| 16 | + |
| 17 | + jSQL.load(function(){ |
| 18 | + |
| 19 | + //// Create a compound key using low-level syntax |
| 20 | + // jSQL.createTable({myTable: [ |
| 21 | + // { name: "ID", type: "INT", args: [] }, |
| 22 | + // { name: "Name", type: "VARCHAR", args: [30] }, |
| 23 | + // { name: "FOOD", type: "VARCHAR", args: [30] } |
| 24 | + // ]}, [ |
| 25 | + // { column: ["ID", "Name"], type: "unique" } |
| 26 | + // ]).execute(data); |
| 27 | + |
| 28 | + //// Create a compund key using high level syntax |
| 29 | + // jSQL.query("create table if not exists myTable (ID int, Name varchar, FOOD varchar, PRIMARY KEY (ID, Name))").execute(data); |
| 30 | + |
| 31 | + // Create a non-compound key using high-level syntax |
| 32 | + jSQL.query("create table if not exists myTable (ID int primary, Name varchar, FOOD varchar)").execute(data); |
| 33 | + |
| 34 | + jSQL.insertInto('myTable').values({ID:0, Name:'Nerd', FOOD: "Bagels"}).ignore().execute(); |
| 35 | + |
| 36 | + console.log("done"); |
| 37 | + }); |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + </script> |
| 44 | + </body> |
| 45 | +</html> |
0 commit comments