npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

datomic-client-js

v0.1.10

Published

Client for Datomic Cloud and Peer Server

Downloads

12

Readme

datomic-client-js

npm version

Work in progress!

API docs

A JavaScript (node, maybe browser) client for Datomic peer server and cloud.

Some example usage:

// peer-server config map example
let peerConf = {
    serverType: 'peer-server',
    endpoint: 'localhost:8001',
    dbName: 'your-db-name',
    accessKey: 'your-access-key',
    secret: 'your-secret'
};

// cloud config map example
let cloudConf = {
    endpoint: 'http://entry.your-system-name.your-region.datomic.net:8182/',
    serverType: 'cloud',
    region: 'your-region',
    system: 'your-system',
    dbName: 'your-db-name',
    proxyPort: 8182  // if connecting via the bastion server
};

let client = require('datomic-client-js');

// List databases, you can omit dbName from config
client.listDatabases(cloudConf).then((dbs) => `${dbs}`);

// Create database (cloud only)
client.createDatabase(cloudConf).then((success) => `${success}`);

// Define for edn string literals (or you can just use jsedn functions).
let edn = client.edn;

// Connect to a database
client.connect(cloudConf).then(async function(connection) {
    // transact a schema
    let schema = edn`[{:db/ident :movie/title,
                       :db/valueType :db.type/string,
                       :db/cardinality :db.cardinality/one,
                       :db/doc "The title of the movie"},
                      {:db/ident :movie/genre,
                       :db/valueType :db.type/string,
                       :db/cardinality :db.cardinality/one,
                       :db/doc "The genre of the movie"},
                      {:db/ident :movie/release-year,
                       :db/valueType :db.type/long,
                       :db/cardinality :db.cardinality/one,
                       :db/doc "The year the movie was released in theaters"}]`;
    await connection.transact({txData: schema});
    
    // transact some data
    let testData = edn`[{:movie/title "The Goonies",
                         :movie/genre "action/adventure",
                         :movie/release-year 1985},
                        {:movie/title "Commando",
                         :movie/genre "thriller/action",
                         :movie/release-year 1985},
                        {:movie/title "Repo Man",
                         :movie/genre "punk dystopia",
                         :movie/release-year 1984}]`;
    await connection.transact({txData: testData});

    // Query the database
    let query = edn`[:find ?movie ?title
                     :in $ ?year
                     :where [?movie :movie/release-year ?year]
                     [?movie :movie/title ?title]]`;
    let db = connection.db();
    // Chunked operations (q, indexRange, datoms, txRange) return a channel that yields
    // promises of async values.
    let chan = await connection.q({query: query, args: [db, 1985]});
    let result = await chan.take();
    
    // Pull an entity
    let id = result[0][0];
    let pulled = await db.pull({
        eid: id,
        selector: edn`[:movie/title :movie/genre :movie/release-year]`    
    });
    return pulled;
});

Status

  • Basic communications work, to the point where I can make a basic query.
  • SPI support for on-prem peer-server.
  • SPI support for cloud.
  • Some query builder support complete.
  • Some transaction builder support complete.
  • EDN queries or transaction data supported.
  • Some tests written.

TODO

  • More builder support for queries.
  • API docs.
  • Package everything properly for external consumption (i.e. I don't really know how to package up JavaScript).
  • More tests.