Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

Commit aacc6ba

Browse files
committed
Parse.com source
1 parent d017eb5 commit aacc6ba

9 files changed

Lines changed: 392 additions & 33 deletions

README.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,15 @@ gulp serve
9999
bower install angular-jsonapi --save
100100
~~~
101101

102-
* Include `angular-jsonapi` and sources modules (`angular-jsonapi-rest`, `angular-jsonapi-local`) in your module's dependencies:
102+
* Include `angular-jsonapi` and sources modules (available: `angular-jsonapi-rest`, `angular-jsonapi-local`, `angular-jsonapi-parse`) in your module's dependencies:
103103

104104
~~~javascript
105105
// in your js app's module definition
106106
angular.module('myApp', [
107107
'angular-jsonapi',
108108
'angular-jsonapi-rest',
109-
'angular-jsonapi-local'
109+
'angular-jsonapi-local',
110+
'angular-jsonapi-parse'
110111
]);
111112
~~~
112113

@@ -316,23 +317,23 @@ To use this source you must include `angular-jsonapi-local` in your module depen
316317
Source constructor takes one argument - prefix for local store objects, default value is `AngularJsonAPI`.
317318
318319
~~~javascript
319-
var localeSynchro = $jsonapi.sourceLocal.create('AngularJsonAPI');
320+
var localSynchro = $jsonapi.sourceLocal.create('Local synchro', 'AngularJsonAPI');
320321
321322
~~~
322323
323324
**Keep in mind that the localStorage size is limited to approx. 5MB on most devices. Exceeding this limit can cause unpredicted results.**
324325
325326
### SourceRest
326327
327-
Is a simple synchronizer with the RESTAPI supporting JSON API format. It performs following operations:
328+
Is a simple source with the RESTAPI supporting JSON API format. It performs following operations:
328329
`remove`, `unlink`, `link`, `update`, `add`, `all`, `get`. Every time the data changes the suitable request is made to keep your data synchronized.
329330
330331
To use this source you must include `angular-jsonapi-rest` in your module dependencies.
331332
332333
Source constructor takes 2 arguments: `name` and `url` of the resource, there is no default value.
333334
334335
~~~javascript
335-
var novelsSynchro = $jsonapi.sourceRest.create('localhost:3000/novels');
336+
var restSynchro = $jsonapi.sourceRest.create('Rest synchro', 'localhost:3000/novels');
336337
337338
~~~
338339
@@ -348,6 +349,31 @@ Encodes params object into `jsonapi` url params schema. Returned object can be t
348349
349350
Decodes params from `jsonapi` url schema (e.g. obtained by `$location.search()).
350351
352+
### SourceParse
353+
354+
**alpha stage, not all options are supported**
355+
356+
If you like the way object are managed by this package, but still you want to use awesome Parse.com API possibilities I got something for you!
357+
358+
SourceParse maps [parse.com](https://parse.com) js sdk to angular-jsonapi schema. It performs following operations:
359+
`remove`, `update`, `add`, `all`, `get`. Every time the data changes the suitable request is made to keep your data synchronized.
360+
361+
`unlink`, `link` operations for hasOne relationship can be made by setting appropriate key to the linked object Id. HasMany relationships are not supported yet.
362+
363+
To use this source you must include `angular-jsonapi-parse` in your module dependencies.
364+
365+
Source constructor takes 2 arguments: `name`, `table` there is no default value. `table` is a name of the mapped object table in [parse.com](https://parse.com) API (usually starts with the capital letter and is singular)
366+
367+
**If you do not use [parse.com](https://parse.com) sdk in other project parts, you have to initialize the source first by calling `parseSynchro.initialize(appId, jsKey)`**
368+
369+
~~~javascript
370+
var parseSynchro = $jsonapi.sourceParse.create('Parse synchro', 'Novel');
371+
372+
//Only if you do not call Parse.initialize somewhere else
373+
parseSource.initialize('JZjOE9MApKqihwZhtOuxs6YkGpXLshUiat63fiCq', '96GQW1YD1J1nG7jesEkA9e9y2ngguzhiXJXYoO2E');
374+
375+
~~~
376+
351377
### Custom Sources
352378
353379
todo
@@ -483,6 +509,7 @@ Params must be an object that can contain keys:
483509

484510
* **include** - string with comma delimited relationships that will override schema settings.
485511
* **filter** - object with `attribute: value` values. Filters are used as 'exact match' (only objects with `attribute` value same as `value` are returned). `value` can also be an array, then only objects with same `attribute` value as one of `values` array elements are returned.
512+
* **limit** - sets quota limit for [parse.com source](#SourceParse).
486513

487514
Those two keys are supported explicitly, but other keys will also be passed to the synchronization.
488515

@@ -733,11 +760,12 @@ Adds each error to `errorsObject.errors[key]`.
733760
## 1.0.0-alpha.7 (in progress)
734761
* [x] fix for one side relationships
735762
* [x] fix for collection.pristine
763+
* [x] Parse.com source alpha
736764
737765
## 1.0.0-alpha.*
766+
* [ ] Parse.com source full support
738767
* [ ] I18n support (medium)
739768
* [ ] File source
740-
* [ ] Parse.com source
741769
* [ ] Add objects for hasMany/hasOne relationship (medium)
742770
* [ ] Protect object attributes from being edited explicitly (without form -> save) (medium)
743771
* [ ] readonly attributes (can't be changed)

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"angular-uuid4": "~0.3.0",
88
"moment": "~2.10.6",
99
"pluralize": "~1.1.5",
10-
"validate": "~0.9.0"
10+
"validate": "~0.9.0",
11+
"parse": "~1.6.7"
1112
},
1213
"ignore": [
1314
"demo/",

dist/angular-jsonapi.js

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

dist/angular-jsonapi.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-jsonapi.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.

dist/angular-jsonapi.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(function() {
2+
'use strict';
3+
4+
angular.module('angular-jsonapi-parse')
5+
.config(provide);
6+
7+
function provide($provide) {
8+
$provide.decorator('$jsonapi', decorator);
9+
}
10+
11+
function decorator($delegate, AngularJsonAPISourceParse) {
12+
var $jsonapi = $delegate;
13+
14+
$jsonapi.sourceLocal = AngularJsonAPISourceParse;
15+
16+
return $jsonapi;
17+
}
18+
})();

0 commit comments

Comments
 (0)