ad526e8794d0966e9f10664e64d1cf0a.json
2.76 KB
{"ast":null,"code":"var _interopRequireWildcard=require(\"@babel/runtime/helpers/interopRequireWildcard\");var SQLite=_interopRequireWildcard(require(\"expo-sqlite\"));var sqlite={};var db=(0,SQLite.openDatabase)(\"score.db\");db.transaction(function(tx){tx.executeSql(\"CREATE TABLE IF NOT EXISTS district (id int AUTO_INCREMENT,score int, PRIMARY KEY (id));\");});sqlite.insert=function(score){db.transaction(function(tx){tx.executeSql(\"INSERT INTO district (score) VALUES (\"+score+\");\");});};sqlite.select=function(){return new Promise(function(resolve,rejects){db.transaction(function(tx){tx.executeSql(\"SELECT score FROM district WHERE 1 ORDER BY id DESC LIMIT 5;\",[],function(tx,result){resolve(result.rows._array);},function(err){console.log(\"err -> \",err);});});});};module.exports=sqlite;","map":{"version":3,"sources":["C:/Users/bluej/Desktop/2_2/searchGuide/searchGuide/lib/sqlite.js"],"names":["sqlite","db","transaction","tx","executeSql","insert","score","select","Promise","resolve","rejects","result","rows","_array","err","console","log","module","exports"],"mappings":"qFAAA,2DAIA,GAAIA,CAAAA,MAAM,CAAG,EAAb,CACA,GAAIC,CAAAA,EAAE,CAAG,wBAAa,UAAb,CAAT,CACAA,EAAE,CAACC,WAAH,CAAgB,SAAEC,EAAF,CAAU,CACtBA,EAAE,CAACC,UAAH,6FACH,CAFD,EAIAJ,MAAM,CAACK,MAAP,CAAgB,SAAEC,KAAF,CAAa,CACzBL,EAAE,CAACC,WAAH,CAAgB,SAAEC,EAAF,CAAU,CACtBA,EAAE,CAACC,UAAH,yCAAuDE,KAAvD,OACH,CAFD,EAGH,CAJD,CAOAN,MAAM,CAACO,MAAP,CAAgB,UAAO,CACnB,MAAO,IAAIC,CAAAA,OAAJ,CAAa,SAACC,OAAD,CAAUC,OAAV,CAAoB,CACpCT,EAAE,CAACC,WAAH,CAAgB,SAAEC,EAAF,CAAU,CACtBA,EAAE,CAACC,UAAH,gEAA+E,EAA/E,CAAmF,SAAED,EAAF,CAAMQ,MAAN,CAAkB,CACjGF,OAAO,CAACE,MAAM,CAACC,IAAP,CAAYC,MAAb,CAAP,CACH,CAFD,CAEG,SAAEC,GAAF,CAAS,CACRC,OAAO,CAACC,GAAR,CAAY,SAAZ,CAAsBF,GAAtB,EACH,CAJD,EAKH,CAND,EAOH,CARM,CAAP,CAUH,CAXD,CAaAG,MAAM,CAACC,OAAP,CAAiBlB,MAAjB","sourcesContent":["import * as SQLite from 'expo-sqlite';\r\nimport { openDatabase,transaction,executeSql } from 'expo-sqlite';\r\n\r\n\r\nlet sqlite = {};\r\nlet db = openDatabase(\"score.db\");\r\ndb.transaction( ( tx ) => {\r\n tx.executeSql(`CREATE TABLE IF NOT EXISTS district (id int AUTO_INCREMENT,score int, PRIMARY KEY (id));`);\r\n});\r\n\r\nsqlite.insert = ( score ) => {\r\n db.transaction( ( tx ) => {\r\n tx.executeSql( `INSERT INTO district (score) VALUES (${score});` );\r\n });\r\n}\r\n\r\n\r\nsqlite.select = ( ) => {\r\n return new Promise( (resolve ,rejects)=>{\r\n db.transaction( ( tx ) => {\r\n tx.executeSql( `SELECT score FROM district WHERE 1 ORDER BY id DESC LIMIT 5;`, [], ( tx, result ) => {\r\n resolve(result.rows._array);\r\n }, ( err )=>{\r\n console.log(\"err -> \",err);\r\n });\r\n });\r\n })\r\n \r\n}\r\n\r\nmodule.exports = sqlite;"]},"metadata":{},"sourceType":"script"}