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

@wymp/sql

v1.0.0-beta21

Published

A small typescript package providing generalized and customizable sql database access

Downloads

4

Readme

Wymp SQL

This is a very experimental attempt at a fully generalized, customizable Typescript database abstraction. While we made an intentional choice to move away from fully declarative method names in favor of more generlized methods, in effect, they remain fairly specific, since you can't call the methods without some fairly specific typing.

The central concept in this library is the "TypeMap". This is a type that you define that links together string type-tags with actual database types, possible filters, possible constraints, and possible default values for fields.

The best example of this can be found in the tests folder, specifically the tests/Types.ts file. This file demonstrates the construction of a simple domain. In reality, you would probably separate types from actual values (like UserDefaults, etc.), but in this case, we've just lumped them all together for ease of use.

As you can see from that example, you have the option of defining constraints (for getting single resources) and filters (for getting collections) on a per-resource basis. You can also define default values (either hard-coded or function-based) for each resource type, allowing you to call save for a new resource without having to provide fields for which reasonable defaults can be found.

Pitfalls

In order to remain useful in the real world, this library must strike a compromise between being generic and also providing strict typing. This means that there are instances in which mistakes can slip through the cracks and produce unexpected issues at runtime. These are not issues that we view as resolvable, since doing so would make the library either too unwieldy or flat out incapable of performing. Following is a running list of those issues:

  • When overriding the getSqlForFilterField method, it is possible to return an array of values when you in fact want to return an array in an array. (TODO: further explain this error)

To-Do

  1. Document TypeGen module
  2. Complete SqlInterface interface
  3. Provide more examples of how to use this library