@@ -50,8 +50,8 @@ class Database
50
50
# create a new one or open an existing database stored in the byte array passed in first argument
51
51
constructor : (data ) ->
52
52
@filename = ' dbfile_' + (0xffffffff * Math .random ()>>> 0 )
53
- if data then FS .createDataFile ' /' , filename, data, true , true
54
- ret = sqlite3_open filename, apiTemp
53
+ if data? then FS .createDataFile ' /' , @ filename , data, true , true
54
+ ret = sqlite3_open @ filename , apiTemp
55
55
if ret isnt SQLite .OK then throw ' SQLite error: ' + SQLite .errorMessages [ret]
56
56
@db = getValue (apiTemp, ' i32' )
57
57
@@ -81,10 +81,6 @@ class Database
81
81
if pStmt is NULL then throw ' Nothing to prepare'
82
82
return new Statement (pStmt)
83
83
84
-
85
- this [' SQL' ] = {' Database' : Database}
86
- if exports ? then exports = this [' SQL' ]
87
-
88
84
getErrors = (ret , errPtrPtr ) ->
89
85
if ret isnt SQLite .OK
90
86
return SQLite .errorMessages [ret]
@@ -179,3 +175,7 @@ SQLite.TEXT=3
179
175
SQLite .BLOB = 4
180
176
SQLite .NULL = 5
181
177
178
+
179
+ # Export the API
180
+ this [' SQL' ] = {' Database' : Database}
181
+ Module[i] = this [' SQL' ][i] for i of this [' SQL' ]
0 commit comments