database-js-firebase
Advanced tools
Comparing version 1.1.3 to 1.1.4
{ | ||
"name": "database-js-firebase", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Database-js interface for Firebase", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node test.js" | ||
}, | ||
@@ -26,3 +26,6 @@ "repository": { | ||
"node-sqlparser": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"database-js": "^3.0.2" | ||
} | ||
} |
# database-js-firebase | ||
[![Build Status](https://travis-ci.org/mlaanderson/database-js-sqlite.svg?branch=master)](https://travis-ci.org/mlaanderson/database-js-sqlite) | ||
Database-js interface for Firebase | ||
## About | ||
@@ -15,5 +18,12 @@ Database-js-firebase is a [database-js](https://github.com/mlaanderson/database-js) wrapper around the Firebase database library. It creates a Promises wrapper around an SQL to Firebase (NoSQL) interpreter. | ||
[RunKit Demo](https://runkit.com/mlaanderson/runkit-npm-database-js2) | ||
## Install | ||
```shell | ||
npm install database-js-firebase | ||
``` | ||
## Usage | ||
If your Firebase data is structured as: | ||
~~~~ | ||
```json | ||
"$uid": { | ||
@@ -34,6 +44,6 @@ "users": { | ||
} | ||
~~~~ | ||
``` | ||
Then your access will be like: | ||
~~~~ | ||
```javascript | ||
var Database = require('database-js2'); | ||
@@ -55,2 +65,6 @@ | ||
})(); | ||
~~~~ | ||
``` | ||
## License | ||
[MIT](https://github.com/mlaanderson/database-js/blob/master/LICENSE) (c) [mlaanderson](https://github.com/mlaanderson) |
38
test.js
var db = require('.'); | ||
(async function () { | ||
let connection = db.open({ | ||
Parameters: "apiKey=AIzaSyD1ypTmnJb_d8ZOyfc-KBMe0tw8owYCwjA", | ||
Hostname: 'statesdemo', | ||
Database: 'ewJviY6wboTKJ57A2dZkvq8kxYo1', | ||
Username: 'user@example.com', | ||
Password: 'password' | ||
}); | ||
let stmt, results; | ||
try { | ||
results = await connection.query('SELECT * FROM states ORDER BY Ranking DESC'); | ||
console.log(results); | ||
} catch (err) { | ||
console.error(err); | ||
} finally { | ||
await connection.close(); | ||
setTimeout(() => { process.exit(); }, 0) | ||
var connection = db.open({ | ||
Parameters: "apiKey=AIzaSyD1ypTmnJb_d8ZOyfc-KBMe0tw8owYCwjA", | ||
Hostname: 'statesdemo', | ||
Database: 'ewJviY6wboTKJ57A2dZkvq8kxYo1', | ||
Username: 'user@example.com', | ||
Password: 'password' | ||
}); | ||
function handleError(error) { | ||
console.log("ERROR:", error); | ||
process.exit(1); | ||
} | ||
connection.query("SELECT * FROM states WHERE State = 'South Dakota'").then((data) => { | ||
if (data.length != 1) { | ||
handleError(new Error("Invalid data returned")); | ||
} | ||
})(); | ||
connection.close().then(() => { | ||
process.exit(0); | ||
}).catch(handleError); | ||
}).catch(handleError); |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
0
68
20362
1