Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keroxp/deno-couchdb
🦕CouchDB client for Deno built top of fetch 🛋
https://github.com/keroxp/deno-couchdb
Last synced: 4 months ago
JSON representation
🦕CouchDB client for Deno built top of fetch 🛋
- Host: GitHub
- URL: https://github.com/keroxp/deno-couchdb
- Owner: keroxp
- License: mit
- Created: 2019-06-01T16:34:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-17T17:42:31.000Z (almost 4 years ago)
- Last Synced: 2024-10-04T11:54:47.500Z (5 months ago)
- Language: TypeScript
- Homepage:
- Size: 63.5 KB
- Stars: 65
- Watchers: 1
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# deno-couchdb
[](https://github.com/keroxp/deno-couchdb/actions)

[](https://github.com/keroxp/deno-couchdb)CouchDB client for Deno built top of fetch
# Usage
```ts
import { CouchClient } from "https://denopkg.com/keroxp/deno-couchdb/couch.ts";export type User = {
id: number;
name: string;
years: number[];
};
async function main() {
// create couch client with endpoint
const couch = new CouchClient("http://localhost:5984");
// choose db to use
const db = couch.database("users");
// check if specified database exists
if (!(await couch.databaseExists("users"))) {
// create new database
await couch.createDatabase("users");
}
// insert new document
const uesr = {
id: 100,
name: "deno",
years: [2018, 2019],
};
const { id, rev } = await db.insert(user);
// get existing document
let user = await db.get(id); // {id: 100, name: "deno", years: [2018,2019]}
// update existing document
user.years.push(2020);
await db.put(id, user, { rev });
// delete existing document
await db.delete(id);
}
```# Compatibility Table
## Document
- [x] `HEAD /{db}/{docid}`
- [x] `GET /{db}/{docid}`
- [x] `PUT /{db}/{docid}`
- [x] `DELETE /{db}/{docid}`
- [x] `COPY /{db}/{docid}`## Attachments
- [x] `HEAD /{db}/{docid}/{attname}`
- [x] `GET /{db}/{docid}/{attname}`
- [x] `PUT /{db}/{docid}/{attname}`
- [x] `DELETE /{db}/{docid}/{attname}`## Server
- WIP...
## Contributing
WELCOME!\
There are still missing features and actually I'm not familiar with CouchDB😇