-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathdatabase.js
More file actions
31 lines (28 loc) · 764 Bytes
/
database.js
File metadata and controls
31 lines (28 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import * as SQLite from 'expo-sqlite';
// openDatabase has been removed from the stable version of expo-sqlite
//import * as SQLite from 'expo-sqlite/legacy';
const database = SQLite.openDatabase('places.db');
export function init() {
const promise = new Promise((resolve, reject) => {
database.transaction((tx) => {
tx.executeSql(
`CREATE TABLE IF NOT EXISTS places (
id INTEGER PRIMARY KEY NOT NULL,
title TEXT NOT NULL,
imageUri TEXT NOT NULL,
address TEXT NOT NULL,
lat REAL NOT NULL,
lng REAL NOT NULL
)`,
[],
() => {
resolve();
},
(_, error) => {
reject(error);
}
);
});
});
return promise;
}