nano-async
v1.0.3
Published
[](https://coveralls.io/github/vanioinformatika/node-nano-async?branch=master) [ (
// Create a server context
const serverAsync = nanoAsync({ url: "http://localhost:5984" })
// Create a document context i.e. a "database" reference
const databaseAsync = serverScope.use("mydb")
// Read a document from the database
const [doc, headers] = await databaseAsync.getAsync(id, { attachments: true })
...
TypeScript
// Import nano and nano-async types
import { default as nanoAsync, ServerScopeAsync, DocumentGetResponse, ... } from "nano-async"
// Import custom document class
import { MyDocument } from "./MyDocument"
// Create a server context
const serverAsync = nanoAsync({ url: "http://localhost:5984" }) as ServerScopeAsync
// Create a document context i.e. a "database" reference
const databaseAsync: DocumentScopeAsync<MyDocument> = serverAsync.use<MyDocument>("mydb")
// Read a document from the database
const [doc, headers] = await databaseAsync.getAsync(id, { attachments: true })
// doc is of type: DocumentGetResponse & MyDocument
...
