Showing
3 changed files
with
36 additions
and
2 deletions
... | @@ -93,7 +93,7 @@ const styles = StyleSheet.create({ | ... | @@ -93,7 +93,7 @@ const styles = StyleSheet.create({ |
93 | }, | 93 | }, |
94 | infoContainer:{ | 94 | infoContainer:{ |
95 | flexDirection:'row', | 95 | flexDirection:'row', |
96 | - justifyContent:'space-around', | 96 | + justifyContent:'center', |
97 | alignItems:'center', | 97 | alignItems:'center', |
98 | width: '100%' | 98 | width: '100%' |
99 | }, | 99 | }, | ... | ... |
searchGuide/lib/sqlite.js
0 → 100644
1 | +import * as SQLite from 'expo-sqlite'; | ||
2 | +import { Modal } from 'react-native'; | ||
3 | +import { openDatabase,transaction,executeSql } from 'expo-sqlite'; | ||
4 | +import { rejects } from 'assert'; | ||
5 | + | ||
6 | + | ||
7 | +let sqlite = {}; | ||
8 | +let db = openDatabase("score.db"); | ||
9 | +db.transaction( ( tx ) => { | ||
10 | + tx.executeSql(`CREATE TABLE IF NOT EXISTS district (id int AUTO_INCREMENT,score int, PRIMARY KEY (id));`); | ||
11 | +}); | ||
12 | + | ||
13 | +sqlite.insert = ( score ) => { | ||
14 | + db.transaction( ( tx ) => { | ||
15 | + tx.executeSql( `INSERT INTO district (score) VALUES (${score});` ); | ||
16 | + }); | ||
17 | +} | ||
18 | + | ||
19 | + | ||
20 | +sqlite.select = ( ) => { | ||
21 | + return new Promise( (resolve ,rejects)=>{ | ||
22 | + db.transaction( ( tx ) => { | ||
23 | + tx.executeSql( `SELECT score FROM district WHERE 1 ORDER BY id DESC LIMIT 5;`, [], ( tx, result ) => { | ||
24 | + resolve(result.rows._array); | ||
25 | + }, ( err )=>{ | ||
26 | + console.log("err -> ",err); | ||
27 | + }); | ||
28 | + }); | ||
29 | + }) | ||
30 | + | ||
31 | +} | ||
32 | + | ||
33 | +module.exports = sqlite; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -31,7 +31,8 @@ | ... | @@ -31,7 +31,8 @@ |
31 | "react-redux": "^7.1.3", | 31 | "react-redux": "^7.1.3", |
32 | "react-thunk": "^1.0.0", | 32 | "react-thunk": "^1.0.0", |
33 | "redux": "^4.0.4", | 33 | "redux": "^4.0.4", |
34 | - "redux-thunk": "^2.3.0" | 34 | + "redux-thunk": "^2.3.0", |
35 | + "expo-sqlite": "~7.0.0" | ||
35 | }, | 36 | }, |
36 | "devDependencies": { | 37 | "devDependencies": { |
37 | "babel-preset-expo": "^7.1.0", | 38 | "babel-preset-expo": "^7.1.0", | ... | ... |
-
Please register or login to post a comment