https://github.com/ampatspell/ember-cli-couch
CouchDB document API for Ember.js
https://github.com/ampatspell/ember-cli-couch
couchdb ember-addon emberjs javascript persistence rest rest-client
Last synced: 3 months ago
JSON representation
CouchDB document API for Ember.js
- Host: GitHub
- URL: https://github.com/ampatspell/ember-cli-couch
- Owner: ampatspell
- License: mit
- Created: 2017-06-02T14:35:02.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-06T12:11:15.000Z (over 7 years ago)
- Last Synced: 2025-04-10T06:04:44.955Z (3 months ago)
- Topics: couchdb, ember-addon, emberjs, javascript, persistence, rest, rest-client
- Language: JavaScript
- Size: 191 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ember-cli-couch
Addon for CouchDB document API.
```
$ ember install ember-cli-couch
```## Setup
``` javascript
// instance-initializers/databases.js
import { registerDatabaseServices } from 'couch';export default {
name: 'thing:databases',
initialize(app) {registerDatabaseServices(app, {
db: {
url: 'http://127.0.0.1:5984',
name: 'thing'
}
});app.lookup('service:db'); // =>
}
};```
## Usage
``` javascript
// routes/index.js
import Ember from 'ember';const {
RSVP: { hash }
} = Ember;export default Ember.Route.extend({
model() {
return hash({
database: this.get('db').info(),
couch: this.get('db.couch').info(),
session: this.get('db.couch.session').load(),
url: this.get('db.url')
});
}
});
```## API
> Full documentation coming soon.
```
couches
couch
couches
url
normalizedUrl
session
load()
save(name, password)
delete()
request(opts)
info()
uuids(count)
changes(opts)
database(name)
couch
name
url
changes(opts)
security
load()
save(body)
design
id(name)
load(name, opts)
save(name, json)
delete(name, opts)
database
info()
create(opts)
delete(opts)
recreate(opts)
mango
find(opts)
explain(opts)
save(ddoc, name, index)
all()
delete()
info()
load(id, opts)
save(doc, opts)
delete(id, rev, opts)
view(ddoc, name, opts)
all(opts)
```## Dummy
See dummy for usage examples and play with `window.db`:
``` javascript
> db.load('first').then(log)
```