Skip to content

Commit 18502ae

Browse files
committed
Stable Version 1.0.0-beta.1.
1 parent bbd6a16 commit 18502ae

File tree

10 files changed

+53
-48
lines changed

10 files changed

+53
-48
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
##### 1.0.0-beta.1 - 10 January 2015
2+
3+
Now in beta.
4+
5+
###### Backwards compatible API changes
6+
- #2 - Authentication
7+
18
##### 1.0.0-alpha.1 - 01 November 2014
29

310
Stable Version 1.0.0-alpha.1

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Jason Dobry
3+
Copyright (c) 2014-2015 Jason Dobry
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<img src="https://raw.githubusercontent.com/js-data/js-data/master/js-data.png" alt="js-data logo" title="js-data" align="right" width="64" height="64" />
22

3-
## js-data-firebase
3+
## js-data-firebase [![Bower version](https://badge.fury.io/bo/js-data-firebase.png)](http://badge.fury.io/bo/js-data-firebase) [![NPM version](https://badge.fury.io/js/js-data-firebase.png)](http://badge.fury.io/js/js-data-firebase)
44

55
Firebase adapter for [js-data](http://www.js-data.io/).
66

bower.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "js-data-firebase",
33
"description": "Firebase adapter for js-data.",
4-
"version": "1.0.0-alpha.1",
54
"homepage": "http://www.js-data.io/docs/dsfirebaseadapter",
65
"repository": {
76
"type": "git",

dist/js-data-firebase.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @author Jason Dobry <[email protected]>
33
* @file js-data-firebase.js
4-
* @version 1.0.0-alpha.1 - Homepage <http://www.js-data.iojs-data-firebase/>
4+
* @version 1.0.0-beta.1 - Homepage <http://www.js-data.iojs-data-firebase/>
55
* @copyright (c) 2014 Jason Dobry
66
* @license MIT <https://github.com/js-data/js-data-firebase/blob/master/LICENSE>
77
*
@@ -179,20 +179,20 @@ function DSFirebaseAdapter(options) {
179179
options = options || {};
180180
this.defaults = new Defaults();
181181
deepMixIn(this.defaults, options);
182+
this.ref = new Firebase(options.basePath || this.defaults.basePath);
182183
}
183184

184185
var dsFirebaseAdapterPrototype = DSFirebaseAdapter.prototype;
185186

186187
dsFirebaseAdapterPrototype.getRef = function (resourceConfig, options) {
187188
options = options || {};
188-
return new Firebase(makePath(options.basePath || this.defaults.basePath || resourceConfig.basePath, options.endpoint || resourceConfig.endpoint));
189+
return this.ref.child(options.endpoint || resourceConfig.endpoint);
189190
};
190191

191192
dsFirebaseAdapterPrototype.find = function (resourceConfig, id, options) {
192193
var _this = this;
193194
return new P(function (resolve, reject) {
194-
var resourceRef = _this.getRef(resourceConfig, options);
195-
resourceRef.child(id).once('value', function (dataSnapshot) {
195+
return _this.getRef(resourceConfig, options).child(id).once('value', function (dataSnapshot) {
196196
resolve(dataSnapshot.val());
197197
}, reject, _this);
198198
});
@@ -201,8 +201,7 @@ dsFirebaseAdapterPrototype.find = function (resourceConfig, id, options) {
201201
dsFirebaseAdapterPrototype.findAll = function (resourceConfig, params, options) {
202202
var _this = this;
203203
return new P(function (resolve, reject) {
204-
var resourceRef = _this.getRef(resourceConfig, options);
205-
resourceRef.once('value', function (dataSnapshot) {
204+
return _this.getRef(resourceConfig, options).once('value', function (dataSnapshot) {
206205
resolve(filter.call(emptyStore, values(dataSnapshot.val()), resourceConfig.name, params, options));
207206
}, reject, _this);
208207
});
@@ -243,8 +242,7 @@ dsFirebaseAdapterPrototype.create = function (resourceConfig, attrs, options) {
243242
dsFirebaseAdapterPrototype.update = function (resourceConfig, id, attrs, options) {
244243
var _this = this;
245244
return new P(function (resolve, reject) {
246-
var resourceRef = _this.getRef(resourceConfig, options);
247-
var itemRef = resourceRef.child(id);
245+
var itemRef = _this.getRef(resourceConfig, options).child(id);
248246
itemRef.once('value', function (dataSnapshot) {
249247
try {
250248
var item = dataSnapshot.val() || {};
@@ -292,8 +290,7 @@ dsFirebaseAdapterPrototype.updateAll = function (resourceConfig, attrs, params,
292290
dsFirebaseAdapterPrototype.destroy = function (resourceConfig, id, options) {
293291
var _this = this;
294292
return new P(function (resolve, reject) {
295-
var resourceRef = _this.getRef(resourceConfig, options);
296-
resourceRef.child(id).remove(function (err) {
293+
_this.getRef(resourceConfig, options).child(id).remove(function (err) {
297294
if (err) {
298295
reject(err);
299296
} else {

dist/js-data-firebase.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,26 @@
1515
.controller('firebaseCtrl', function ($scope, User) {
1616
var fCtrl = this;
1717

18-
User.findAll().then(function (users) {
19-
$scope.users = users;
20-
$scope.$apply();
18+
User.findAll().then(function () {
19+
$scope.$apply(function () {
20+
$scope.users = User.filter();
21+
});
2122
});
2223

2324
$scope.add = function (user) {
2425
User.create(user).then(function () {
2526
fCtrl.name = '';
26-
$scope.$apply();
27+
$scope.$apply(function () {
28+
$scope.users = User.filter();
29+
});
2730
});
2831
};
2932

3033
$scope.remove = function (user) {
3134
User.destroy(user.id).then(function () {
32-
$scope.$apply();
35+
$scope.$apply(function () {
36+
$scope.users = User.filter();
37+
});
3338
});
3439
};
3540
});

example/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
77
<link href="./example.css" rel="stylesheet">
88
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
9-
<script src="https://cdn.firebase.com/js/client/1.1.2/firebase.js"></script>
10-
<script src="https://github.com/js-data/js-data/releases/download/1.0.0-alpha.1-0/js-data-1.0.0-alpha.1-0.min.js"></script>
9+
<script src="https://cdn.firebase.com/js/client/1.1.3/firebase.js"></script>
10+
<script src="https://github.com/js-data/js-data/releases/download/1.0.0-beta.1/js-data-1.0.0-beta.1.min.js"></script>
1111
<script
12-
src="https://github.com/js-data/js-data-firebase/releases/download/0.4.3/js-data-firebase-0.4.3.min.js"></script>
12+
src="https://github.com/js-data/js-data-firebase/releases/download/1.0.0-beta.1/js-data-firebase-1.0.0-beta.1.min.js"></script>
1313
<script src="./example.js"></script>
1414
</head>
1515
<body data-ng-controller="firebaseCtrl as fCtrl">
1616
<div class="example-masthead">
1717
<div class="container">
1818
<nav class="example-nav">
1919
<a class="example-nav-item" href="http://www.js-data.io">js-data.io</a>
20-
<a class="example-nav-item" href="http://www.js-data.io/v0.4.2/docs/dsfirebaseadapter">API Documentation</a>
20+
<a class="example-nav-item" href="http://www.js-data.io/docs/dsfirebaseadapter">API Documentation</a>
2121
<a class="example-nav-item" href="https://github.com/js-data/js-data-firebase">GitHub</a>
2222
<a class="example-nav-item" href="https://groups.io/org/groupsio/jsdata">Mailing List</a>
2323
<a class="example-nav-item" href="https://github.com/js-data/js-data-firebase/issues">Issues</a>

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-data-firebase",
33
"description": "Firebase adapter for js-data.",
4-
"version": "1.0.0-alpha.1",
4+
"version": "1.0.0-beta.1",
55
"homepage": "http://www.js-data.io/docs/dsfirebaseadapter",
66
"repository": {
77
"type": "git",
@@ -29,32 +29,32 @@
2929
"main": "./src/index.js",
3030
"devDependencies": {
3131
"grunt": "0.4.5",
32-
"grunt-browserify": "3.0.1",
32+
"grunt-browserify": "3.2.1",
3333
"grunt-contrib-clean": "0.6.0",
3434
"grunt-contrib-jshint": "0.10.0",
35-
"grunt-contrib-uglify": "0.6.0",
35+
"grunt-contrib-uglify": "0.7.0",
3636
"grunt-contrib-watch": "0.6.1",
37-
"grunt-karma": "0.9.0",
38-
"grunt-karma-coveralls": "2.5.2",
39-
"karma": "0.12.24",
37+
"grunt-karma": "0.10.1",
38+
"grunt-karma-coveralls": "2.5.3",
39+
"karma": "0.12.31",
4040
"karma-chai": "0.1.0",
41-
"karma-chrome-launcher": "0.1.5",
42-
"karma-coverage": "0.2.6",
41+
"karma-chrome-launcher": "0.1.7",
42+
"karma-coverage": "0.2.7",
4343
"karma-script-launcher": "0.1.0",
44-
"karma-firefox-launcher": "0.1.3",
44+
"karma-firefox-launcher": "0.1.4",
4545
"karma-phantomjs-launcher": "0.1.4",
46-
"karma-mocha": "0.1.9",
47-
"karma-sinon": "1.0.3",
48-
"karma-spec-reporter": "0.0.13",
46+
"karma-mocha": "0.1.10",
47+
"karma-sinon": "1.0.4",
48+
"karma-spec-reporter": "0.0.16",
4949
"time-grunt": "1.0.0",
5050
"jit-grunt": "0.9.0"
5151
},
5252
"scripts": {
5353
"test": "grunt test"
5454
},
5555
"dependencies": {
56-
"mout": "0.10.0",
57-
"js-data": "~1.0.x",
58-
"firebase": "~1.1.x"
56+
"mout": "0.11.0",
57+
"js-data": "^1.0.0-beta.1",
58+
"firebase": "~2.1.x"
5959
}
6060
}

src/index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ function DSFirebaseAdapter(options) {
3838
options = options || {};
3939
this.defaults = new Defaults();
4040
deepMixIn(this.defaults, options);
41+
this.ref = new Firebase(options.basePath || this.defaults.basePath);
4142
}
4243

4344
var dsFirebaseAdapterPrototype = DSFirebaseAdapter.prototype;
4445

4546
dsFirebaseAdapterPrototype.getRef = function (resourceConfig, options) {
4647
options = options || {};
47-
return new Firebase(makePath(options.basePath || this.defaults.basePath || resourceConfig.basePath, options.endpoint || resourceConfig.endpoint));
48+
return this.ref.child(options.endpoint || resourceConfig.endpoint);
4849
};
4950

5051
dsFirebaseAdapterPrototype.find = function (resourceConfig, id, options) {
5152
var _this = this;
5253
return new P(function (resolve, reject) {
53-
var resourceRef = _this.getRef(resourceConfig, options);
54-
resourceRef.child(id).once('value', function (dataSnapshot) {
54+
return _this.getRef(resourceConfig, options).child(id).once('value', function (dataSnapshot) {
5555
resolve(dataSnapshot.val());
5656
}, reject, _this);
5757
});
@@ -60,8 +60,7 @@ dsFirebaseAdapterPrototype.find = function (resourceConfig, id, options) {
6060
dsFirebaseAdapterPrototype.findAll = function (resourceConfig, params, options) {
6161
var _this = this;
6262
return new P(function (resolve, reject) {
63-
var resourceRef = _this.getRef(resourceConfig, options);
64-
resourceRef.once('value', function (dataSnapshot) {
63+
return _this.getRef(resourceConfig, options).once('value', function (dataSnapshot) {
6564
resolve(filter.call(emptyStore, values(dataSnapshot.val()), resourceConfig.name, params, options));
6665
}, reject, _this);
6766
});
@@ -102,8 +101,7 @@ dsFirebaseAdapterPrototype.create = function (resourceConfig, attrs, options) {
102101
dsFirebaseAdapterPrototype.update = function (resourceConfig, id, attrs, options) {
103102
var _this = this;
104103
return new P(function (resolve, reject) {
105-
var resourceRef = _this.getRef(resourceConfig, options);
106-
var itemRef = resourceRef.child(id);
104+
var itemRef = _this.getRef(resourceConfig, options).child(id);
107105
itemRef.once('value', function (dataSnapshot) {
108106
try {
109107
var item = dataSnapshot.val() || {};
@@ -151,8 +149,7 @@ dsFirebaseAdapterPrototype.updateAll = function (resourceConfig, attrs, params,
151149
dsFirebaseAdapterPrototype.destroy = function (resourceConfig, id, options) {
152150
var _this = this;
153151
return new P(function (resolve, reject) {
154-
var resourceRef = _this.getRef(resourceConfig, options);
155-
resourceRef.child(id).remove(function (err) {
152+
_this.getRef(resourceConfig, options).child(id).remove(function (err) {
156153
if (err) {
157154
reject(err);
158155
} else {

0 commit comments

Comments
 (0)