Coder Social home page Coder Social logo

deno-couchdb's Introduction

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...

deno-couchdb's People

Contributors

keroxp avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.