-
Notifications
You must be signed in to change notification settings - Fork 11
/
Fable.ReactNativeSqlite.fs
92 lines (71 loc) · 3.25 KB
/
Fable.ReactNativeSqlite.fs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
namespace rec Fable.ReactNativeSqlite
open Fable.Core.JsInterop
open System
open Fable.Core
open Fable.Core.JS
type [<AllowNullLiteral>] IExports =
abstract DEBUG: isDebug: bool -> unit
abstract enablePromise: enablePromise: bool -> unit
abstract openDatabase: ``params``: DatabaseParams -> Promise<SQLiteDatabase>
abstract deleteDatabase: ``params``: DatabaseParams -> Promise<unit>
type [<StringEnum>] [<RequireQualifiedAccess>] Location =
| Default
| [<CompiledName "Library">] Library
| [<CompiledName "Documents">] Documents
type [<AllowNullLiteral>] DatabaseOptionalParams =
abstract createFromLocation: U2<float, string> option with get, set
abstract key: string option with get, set
abstract readOnly: bool option with get, set
type [<AllowNullLiteral>] DatabaseParams =
inherit DatabaseOptionalParams
abstract name: string with get, set
/// Affects iOS database file location
/// 'default': Library/LocalDatabase subdirectory - NOT visible to iTunes and NOT backed up by iCloud
/// 'Library': Library subdirectory - backed up by iCloud, NOT visible to iTunes
/// 'Documents': Documents subdirectory - visible to iTunes and backed up by iCloud
abstract location: Location with get, set
type [<AllowNullLiteral>] ResultSet =
abstract insertId: int with get, set
abstract rowsAffected: int with get, set
abstract rows: ResultSetRowList with get, set
type [<AllowNullLiteral>] ResultSetRowList =
abstract length: int with get, set
abstract item: index: int -> obj option
type [<RequireQualifiedAccess>] SQLErrors =
| UNKNOWN_ERR = 0
| DATABASE_ERR = 1
| VERSION_ERR = 2
| TOO_LARGE_ERR = 3
| QUOTA_ERR = 4
| SYNTAX_ERR = 5
| CONSTRAINT_ERR = 6
| TIMEOUT_ERR = 7
type [<AllowNullLiteral>] SQLError =
abstract code: float with get, set
abstract message: string with get, set
type [<AllowNullLiteral>] StatementCallback =
[<Emit "$0($1...)">] abstract Invoke: transaction: Transaction * resultSet: ResultSet -> unit
type [<AllowNullLiteral>] StatementErrorCallback =
[<Emit "$0($1...)">] abstract Invoke: transaction: Transaction * error: SQLError -> unit
type [<AllowNullLiteral>] Transaction =
abstract executeSql: sqlStatement: string * ?arguments: obj [] -> Transaction * SqlResults
type [<AllowNullLiteral>] TransactionCallback =
[<Emit "$0($1...)">] abstract Invoke: transaction: Transaction -> unit
type [<AllowNullLiteral>] TransactionErrorCallback =
[<Emit "$0($1...)">] abstract Invoke: error: SQLError -> unit
type SqlResults =
class end
with
member this.results : ResultSetRowList =
let y : ResultSet [] = unbox this
y.[0].rows
type [<AllowNullLiteral>] SQLiteDatabase =
abstract transaction: scope: (Transaction -> unit) -> Promise<Transaction>
abstract readTransaction: scope: (Transaction -> unit) -> Promise<TransactionCallback>
abstract close: unit -> Promise<unit>
abstract executeSql: statement: string * ?``params``: obj [] -> Promise<SqlResults>
abstract attach: nameToAttach: string * alias: string -> Promise<unit>
abstract dettach: alias: string -> Promise<unit>
[<AutoOpen>]
module Helpers =
let SQLite : IExports = importDefault "react-native-sqlite-storage"