About
jugglindb-cozy-adapter is an adapter for JugglingDB required by cozy applications to use the Cozy Data System.
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 Noteexists 123 consolelog isExist # Find Notefind 321 consolelog note # Create Notecreate id: "321""content":"created value" consolelog noteid # Update notesave consolelog err # Update attributes noteupdateAttributes title: "my new title" consolelog err # Upsert NotecreateOrUpdate @dataid consolelog err # Delete notedestroy consolelog err
Indexation
# Index document fields noteindex "title""content" consolelog err # Search through indexes Notesearch "dragons" consolelog notes
Files
# Attach file noteattachFile "./test.png" consolelog err # Get file stream = @notegetFile "test.png" consolelog errstreampipe fscreateWriteStream'./test-get.png'
Requests
# Define request = emit doc_iddoc return NotedefineRequest "every_notes"map consolelog err # Get request results Noterequest "every_notes" consolelog notes # Destroy documents through request results NoterequestDestroy "every_notes"key: ids3 # Remove request NoteremoveRequest "every_notes" consolelog err
Accounts
# Create dataMailBox = name: "test mailBox" id: "110"MailBoxcreate dataMailBox dataAccount = pwd: "password" login: "log" mailBoxcreateAccount dataAccount consolelog accountid # Get mailBoxgetAccount consolelog account # Update data = pwd: "newPassword" login: "newLog"mailBoxupdateAccount data consolelog err # Update attributes mailBoxmergeAccount login: "newLog" consolelog err # Delete mailBoxdestroy consolelog err
Build & tests
To build source to JS, run
cake build
To run tests:
cake tests
What is Cozy?
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