Dracula
“I vant to drink your data”
Dracula (inspired by DatQL-a or dat-quill-a) is a small JavaScript module for running DatQL queries directly against your database, as opposed to simply returning the generated SQL. You can install it via NPM or Yarn:
$ npm install dracula --save-dev$ yarn add dracula --dev
Be sure to install v0.0.3 or up, or else you'll get the original library registered under the "dracula" package name (a now defunct package by Bozhidar Dryanovski).
The API is incredibly simple to use, and is designed only for recent versions of Node. For example, to hook DatQL into Postgres using Dracula:
;;; const pool = /* pg config object */; // Define a queryconst query = dql`query getUser($id) { users(id = $id) { name email }}`; // Create a hook to connect DQL to your database// Queries are always passed to the callback in their parameterized object formconst db = ; const getUser = ; // You can now pass a config object to getUser() to retrieve a user by its ID;
You can omit some of the above code by doing merging the db
variable with the
dracula
include directly:
const dracula = async { pool; };
Please note that the API is still relatively new and may change in the future.