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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zthun/dalmart-db

v1.6.6

Published

A set of interfaces and option builders for database manipulation.

Downloads

255

Readme

Dalmart Database

This is the root package of the dalmart system. This package contains all of the generic options and interface declarations that are needed to grab a connection to a database server.

Installation

npm install @zthun/dalmart-db
yarn add @zthun/dalmart-db

Document Database

Document databases store "documents," usually in a json like format with key value pairs for quick lookups and queries. The most popular document database that most people know is mongo.

Dalmart's document database layer comes with the needed method implementations for create, read, update, and delete; however, unlike systems such as mongoose, which only operate on a single document at a time, dalmart is build with bulk in mind. Rather than updating documents one by one, every CRUD operation assumes that you want to do bulk operations out of the box. This means, that if you want to do one document, you pass a collection with 1 item in it instead of calling a different method, or worse, looping through a list and inserting, updating, or removing one at a time.

Dalmart also makes use of @zthun/helpful-query to do the sorting and filtering, abstracting away the need to have vendor locked apis around those operations. This makes it so a dalmart implementation supplies the L in SOLID. You can simply substitute any implementation of a document database with a different vendor and it's a drop in place operation.

Document Database Example

import { IZDatabaseDocument } from "@zthun/dalmart-db";
import {
  ZFilterBinaryBuilder,
  IZPage,
  ZPageBuilder,
} from "@zthun/helpful-query";

export class PokemonService {
  public static readonly Collection = "Pokemon";

  public constructor(private _dal_: IZDatabaseDocument) {}

  public async list(req: IZDataRequest): Promise<IZPage<IZPokemon>> {
    const count = await this._dal.count(PokemonService.Collection, req);
    const data = await this._dal.read(PokemonService.Collection, req);
    return new ZPageBuilder().count(count).data(data).build();
  }

  public async get(id: string): Promise<IZPokemon | undefined> {
    const byId = new ZDataFilterBinaryBuilder()
      .subject("_id")
      .equals()
      .value(id)
      .build();
    const req = new ZDataRequestBuilder().page(1).size(1).filter(byId).build();
    const [result] = await this._dal.read(PokemonService.Collection, req);
    return result;
  }

  public async create(template: IZPokemon): Promise<IZPokemon> {
    // Dalmart always operates with bulk in mind.
    const [result] = await this._dal.create(PokemonService.Collection, [
      template,
    ]);
    return result;
  }

  public async createAll(templates: IZPokemon[]): Promise<IZPokemon[]> {
    return this._dal.create(PokemonService.Collection, templates);
  }

  public update(template: Partial<IZPokemon>, filter: IZFilter) {
    // Everything matching the filter will be updated with the given template partial.
    return this._dal.update(PokemonService.Collection, template, filter);
  }

  public delete(id: string) {
    const byId = new ZDataFilterBinaryBuilder()
      .subject("_id")
      .equals()
      .value(id)
      .build();
    await this._dal.delete(PokemonService.Collection, byId);
  }

  public purge() {
    // Dumps the entire collection.
    await this._dal.delete(PokemonService.Collection);
  }
}

Memory Database

Memory databases are different than document and relational databases. Memory databases use key value pair lookups to store and retrieve data. If you have ever used localStorage, sessionStorage, or redis, you will be familiar with this concept.

Unlike document databases, these kinds of database do not have query support and are mostly useful when you need quick lookups of data. The two main concepts of them are read and upsert.

Memory Database Example

export class PokemonCache {
  public constructor(private _dal: IZDatabaseMemory) {}

  public async read(id: string, retrieve: () => Promise<IZPokemon>) {
    const result = await this._dal.read(id);

    if (result != null) {
      return result;
    }

    const value = await retrieve();
    return this.put(id, value);
  }

  public update(key: string, value: IZPokemon): Promise<IZPokemon> {
    return this._dal.upsert(key, value);
  }

  public bust(id: string): Promise<void> {
    await this._dal.delete(key);
  }
}

Relational Database

Currently, Dalmart does not support relational databases as these are MUCH more complex than the others. This may come in the future if the need comes up, but for now, only document and memory databases are supported.