{
"_id": "5c5014569fa4f109c4c310eb26001157",
"_rev": "1-6e67347a1a2d73a89b5b8fab2060083a",
"type": "host",
"label": "dev server",
"host": "dev.example.com",
"username": "root",
"password": "smalldick",
"platform": "ubuntu",
"port": 22,
"tags": [
"dev",
"ubuntu",
"aws"
],
"groups": [
"home",
"dev"
]
}
$ curl http://localhost:5984/hosts/003EB430-4C46-0FA1-8669-A600D0D92C87
{
"_id": "003EB430-4C46-0FA1-8669-A600D0D92C87",
"_rev": "1-6e67347a1a2d73a89b5b8fab2060083a",
"type": "host",
"label": "dev server",
"host": "dev.example.com",
"username": "root",
"password": "smalldick",
"platform": "ubuntu",
"port": 22,
"tags": [
"dev",
"ubuntu",
"aws"
],
"groups": [
"home",
"dev"
]
}
$ curl -X DELETE http://localhost:5984/hosts/003EB430-4C46-0FA1-8669-A600D0D92C87
# Tags
(doc, request) ->
if doc.type == 'host'
for tag in doc.tags
emit(doc._id, tag)
# Filter: hosts
(doc, request) ->
return doc.type == 'host'
# Validation function
(newDoc, oldDoc, userCtx) ->
if doc.type == 'host'
if not isNumber(doc.host)
throw({forbidden: message});