Skip to content

Commit

Permalink
Update README and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhduong committed Apr 28, 2018
1 parent 7fedc79 commit 2c90149
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
- 📊 Have some drivers for `firebase realtime db` or any storage libraries...

### Basic example
#### Node or browser
```ts
// ES6
import { Queryable } from 'linq-fns';

// ES5
const Queryable = require('linq-fns').Queryable;

let query = Queryable
.from(nations)
.join(continents, (x, y) => x.areaId === y.id)
Expand All @@ -28,6 +35,25 @@ asyncData.then(data => {
});
```

#### Firebase
``` ts
const FireBaseQueryale = require('linq-fns').FireBaseQueryale;
const admin = require('firebase-admin');
const serviceAccount = require('./serviceAccountKey');

admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://xxx.firebaseio.com'
});

const db = admin.database();
const firebaseQuery = new FireBaseQueryale(db);

const postsQuery = firebaseQuery.getRepository('<rootTable>.<childTables>.<child...>');
// Then using like Queryable Apis

```

### Process
- [x] from
- [x] where
Expand Down
1 change: 1 addition & 0 deletions src/drivers/linq-fns-firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class FireBaseQueryale {
}

private convert<T>(objData: Object): T[] {
if (!objData) return [];
return Object.keys(objData).map(prop => {
objData[prop]['__id'] = prop;
return objData[prop];
Expand Down

0 comments on commit 2c90149

Please sign in to comment.