https://github.com/sroehrl/angularjs-neoan-flatdb
https://github.com/sroehrl/angularjs-neoan-flatdb
angularjs database offline-first
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sroehrl/angularjs-neoan-flatdb
- Owner: sroehrl
- Created: 2018-09-23T01:58:39.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-29T19:30:25.000Z (almost 8 years ago)
- Last Synced: 2025-01-06T07:12:34.566Z (over 1 year ago)
- Topics: angularjs, database, offline-first
- Language: JavaScript
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# angularjs-neoan-flatDb
Deployable, indexed, offline-first Database for AngularJS
Keeps the necessary abstraction-level for your apps when dealing with packaged,
offline applications while providing queryable data.
>bower install https://github.com/sroehrl/angularjs-neoan-flatDb.git --save
### [AngularJS](https://angularjs.org) module
```
angular.module('your-app',['neoan.nfdb']);
```
## Usage
>The usage depends on your type of application and differs greatly.
>This is just a very basic demonstration based on a common use-case.
### In JS
>! Inject $db !
```JS
// Connect to a destination (the file-ending .nfdb is optional).
// A JSON format is required
$db.connect('data.nfdb').then(function(dbService){
// You can assign the service to the current scope
$scope.db = dbService;
// Query data by object
let results = $scope.db.query({inHere:{someKey:'someValue'}});
// The property attach() is provided to all arrays and objects to easily
// add entries.
let newUser = {name:'Charlie', gender:'male'};
results.forEach(function(item){
item.attach(newUser).then(function(user){
// 'user' contains attach-functions, its value as well as
// an id (_nId, (UUID)). Adding the member _nId in attach() enables
// the usage of own ids
})
});
// To create or update data, to create a level-1 store
// or to create an indexed object prior to any attachments, use put()
// e.g. creating entity for users
$scope.db.put({'users':[]}).then(function(users){
// 'users' contains attach-functions, an empty array as well as
// an id (_nId, (UUID)). Adding the member _nId in put() enables
// the usage of own ids
})
});
```
### In HTML
```HTML
Get Charlie's blog posts!
```