Created
July 10, 2017 20:18
-
-
Save yyssjj33/e0a523d7e0d56332bf93d653db356c70 to your computer and use it in GitHub Desktop.
demo for web sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var order = { | |
orderId: 100314, format_city: "New York, NY, USA", | |
lat: 40.7127837, lng: -74.0059413, | |
price: 150, createTime: "2017-06-08" | |
}; | |
const db = window.openDatabase("order_test", "1.0", "order map data", 2*1024*1024) | |
db.transaction(function(tx){ | |
tx.executeSql( "create table if not exists order_data(order_id primary key, format_city, lat, lng, price, create_time)", [], null, | |
function(tx, err){ | |
throw(`execute sql failed: ${err.code} ${err.message}`); | |
}); | |
tx.executeSql(`insert into order_data values(${order.orderId}, '${order.format_city}', | |
${order.lat}, ${order.lng}, ${order.price}, '${date}')`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment