0.4.15 • Published 9 years ago

jugglingdb-cozy-adapter v0.4.15

Weekly downloads
7
License
-
Repository
github
Last release
9 years ago

About

jugglindb-cozy-adapter is an adapter for JugglingDB required by cozy applications to use the Cozy Data System.

Build
Status

Setup for Compound

First add it to your project dependencies (package.json file), or install it directly:

npm install jugglingdb-cozy-adapter

Then in your config/database.json file, add this:

{
    "driver":   "jugglingdb-cozy-adapter",
    "url": "http://localhost:9101/"
}

Url parameter is optional. Don't forget the trailing slash at the end of the url. Of course to work correctly, the adapter required Cozy Data System and CouchDB up and running.

Usage

Check test file for documented usage of methods available in this adapter.

Documents

# Existence
Note.exists 123, (err, isExist) ->
    console.log isExist

# Find
Note.find 321, (err, note) ->
    console.log note

# Create
Note.create { id: "321", "content":"created value"}, (err, note) ->
    console.log note.id

# Update
note.save (err) ->
    console.log err

# Update attributes
note.updateAttributes title: "my new title", (err) ->
    console.log err

# Upsert
Note.createOrUpdate @data.id, (err, note) ->
    console.log err

# Delete
note.destroy (err) ->
    console.log err

Indexation

# Index document fields
note.index ["title", "content"], (err) ->
    console.log err

# Search through indexes
Note.search "dragons", (err, notes) ->
    console.log notes

Files

# Attach file
note.attachFile "./test.png", (err) ->
    console.log err

# Get file
stream = @note.getFile "test.png", (err) ->
     console.log err
stream.pipe fs.createWriteStream('./test-get.png')

Requests

# Define request
map = (doc) ->
    emit doc._id, doc
    return

Note.defineRequest "every_notes", map, (err) ->
    console.log err

# Get request results
Note.request "every_notes", (err, notes) ->
    console.log notes

# Destroy documents through request results
Note.requestDestroy "every_notes", {key: ids[3]}, (err) ->

# Remove request
Note.removeRequest "every_notes", (err) ->
     console.log err

Accounts

# Create
dataMailBox =
    name: "test mailBox"
    id: "110"
MailBox.create dataMailBox, (err, mailBox) =>
    dataAccount =
        pwd: "password"
        login: "log"
    mailBox.createAccount dataAccount, (err, account) ->
        console.log account.id

# Get
mailBox.getAccount (err, account) ->
    console.log account

# Update
data =
    pwd: "newPassword"
    login: "newLog"
mailBox.updateAccount data, (err) ->
    console.log err

# Update attributes
mailBox.mergeAccount login: "newLog", (err) ->
    console.log err

# Delete
mailBox.destroy (err) ->
    console.log err

Build & tests

To build source to JS, run

cake build

To run tests:

cake tests

What is Cozy?

Cozy Logo

Cozy is a platform that brings all your web services in the same private space. With it, your web apps and your devices can share data easily, providing you with a new experience. You can install Cozy on your own hardware where no one profiles you.

Community

You can reach the Cozy Community by:

  • Chatting with us on IRC #cozycloud on irc.freenode.net
  • Posting on our Forum
  • Posting issues on the Github repos
  • Mentioning us on Twitter
0.4.15

9 years ago

0.4.14

9 years ago

0.4.13

10 years ago

0.4.12

10 years ago

0.4.11

10 years ago

0.4.10

10 years ago

0.4.9

10 years ago

0.4.8

10 years ago

0.4.7

10 years ago

0.4.6

10 years ago

0.4.5

10 years ago

0.4.4

10 years ago

0.4.3

10 years ago

0.4.1

10 years ago

0.4.0

11 years ago

0.3.14

11 years ago

0.3.12

11 years ago

0.3.11

11 years ago

0.3.9

11 years ago

0.3.8

11 years ago

0.3.7

11 years ago

0.3.6

11 years ago

0.3.5

11 years ago

0.3.3

11 years ago

0.3.2

11 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.2.3

12 years ago

0.2.2

12 years ago

0.2.1

12 years ago

0.2.0

12 years ago

0.1.4

12 years ago

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago