Skip to content
CouchDB client for Deno built top of fetch
Branch: master
Clone or download
Latest commit 1e15a9c Jun 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig add: first commit Jun 1, 2019
.gitignore ci: add tsconfig Jun 3, 2019
.travis.yml bump: deno v0.9.0 (#2) Jun 16, 2019
LICENSE Initial commit Jun 1, 2019
README.md bump: deno v0.9.0 (#2) Jun 16, 2019
couch.ts bump: deno v0.9.0 (#2) Jun 16, 2019
couch_test.ts bump: deno v0.9.0 (#2) Jun 16, 2019
tsconfig.json ci: add tsconfig Jun 3, 2019
updb.sh add: first commit Jun 1, 2019

README.md

deno-couchdb

https://travis-ci.com/keroxp/deno-couchdb https://img.shields.io/github/tag/keroxp/deno-couchdb.svg license tag tag

CouchDB client for Deno built top of fetch

Usage

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<User>("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

  • HEAD /{db}/{docid}
  • GET /{db}/{docid}
  • PUT /{db}/{docid}
  • DELETE /{db}/{docid}
  • COPY /{db}/{docid}

Attachments

  • HEAD /{db}/{docid}/{attname}
  • GET /{db}/{docid}/{attname}
  • PUT /{db}/{docid}/{attname}
  • DELETE /{db}/{docid}/{attname}

Server

  • WIP...

Contributing

WELCOME!
There are still missing features and actually I'm not familiar with CouchDB😇

You can’t perform that action at this time.