1 | # Americano Cozy
|
2 |
|
3 | When you want to write [Cozy](http://cozy.io) applications with
|
4 | [Americano](https://github.com/frankrousseau/americano), you don't have the
|
5 | good helpers to write your models. Here are some that could make your life
|
6 | easier, notably about declaring your requests.
|
7 |
|
8 | ## Getting Started
|
9 |
|
10 | Add americano-cozy to the list of your plugins in the Americano configuration file. Then add it as a dependency of your project:
|
11 |
|
12 | npm install americano-cozy -g
|
13 |
|
14 |
|
15 | ## Models
|
16 |
|
17 | Do no think about including JugglingDB and its configuration for Cozy
|
18 | anymore, Americano Cozy does the job for you:
|
19 |
|
20 |
|
21 | ```coffeescript
|
22 | americano = require 'americano-cozy'
|
23 |
|
24 | module.exports = americano.getModel 'Task',
|
25 | done: Boolean
|
26 | completionDate: Date
|
27 | ```
|
28 |
|
29 | ## Requests
|
30 |
|
31 | Describe your Data System requests in a single file:
|
32 |
|
33 | ```coffeescript
|
34 | # server/models/requests.coffee
|
35 | americano = require 'americano-cozy'
|
36 |
|
37 | module.exports =
|
38 | task:
|
39 | all: americano.defaultRequests.all
|
40 | analytics:
|
41 | map: (doc) ->
|
42 | if doc.completionDate? and doc.done
|
43 | date = new Date doc.completionDate
|
44 | dateString = "#{date.getFullYear()}-"
|
45 | dateString += "#{date.getMonth() + 1}-#{date.getDate()}"
|
46 | emit dateString, 1
|
47 | reduce: (key, values, rereduce) ->
|
48 | sum values
|
49 | ```
|
50 |
|
51 | ## What about contributions?
|
52 |
|
53 | Here is what I would like to do next:
|
54 |
|
55 | * write tests
|
56 | * remove async from the dependency (use recursive functions instead)
|
57 | * make Data System URL configurable
|
58 |
|
59 | I didn't start any development yet, so you're welcome to participate!
|