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

lambdaorm

v2.3.2

Published

ORM

Downloads

394

Readme

λORM

Join the community on GitHub Discussions Slack Gitter Discord Wiki language typescript npm version License: MIT semantic-release Github CI CLI Api REST

λORM is an ORM that allows us to perform distributed queries on different database engines.

In λORM, queries are defined using lambda expressions based on a domain model which abstracts us from the infrastructure. For example, in a query you can obtain or modify records from different entities, where some persist in MySQL, others in Postgres, and others in Mongo.

λORM allows you to define different scenarios for the same domain. For example, in one scenario, the infrastructure may consist of distributed instances across SQL Server, MongoDB, and Oracle, while in another scenario it may be a single Postgres instance. This allows the CQRS pattern to be implemented through configuration, without needing to write a single line of code. view example

In addition to being used as a Node.js library, it can be consumed from a command line interface (CLI), a REST service, or a REST service client in other programming languages.

Query Language

Example of a query where orders and their details associated with a customer are obtained:

const query = (country: string) => Products
    .map(p => ({ category: p.category.name, largestPrice: max(p.price) }))    
    .filter(p => (p.price > 5 && p.supplier.country == country) || (p.inStock < 3))    
    .having(p => max(p.price) > 50)
    .sort(p => desc(p.largestPrice));
// Run the query passing the value of the country parameter
const result = await orm.execute(query, { country: 'ARG' });

In this example:

  • Define a query that returns a list of product categories along with the maximum price of each category.
  • Filter products based on price and supplier's country or stock availability
  • Group products by category and calculate the maximum price
  • Map each product to an object with category name and maximum price
  • Sort the products by largest price in descending order

view: queries | select | join | grouping | include | insert | bulkInsert | update | delete | repository | usage | metadata

Include

The include allows us to obtain the entity data and its relationships in the same query. These data may be in different databases.
In this example the query is expressed as a text string. (Which is another alternative to the lambda expression)

import { orm } from '../../lib'
(async () => {
  try {
    await orm.init('./config/northwind.yaml')
    const query = `Orders
	.filter(p => p.id === id)
	.include(p => 
	  [ p.customer.map(p => p.name), 
	    p.details
             .include(p => 
                 p.product
  	          .include(p => p.category.map(p => p.name))
		  .map(p => p.name))
	     .map(p => [p.quantity, p.unitPrice])
	   ]
         )`
	const params = { id: 102 }
	const result = await orm.execute(query, params, { stage: 'PostgreSQL' })
	console.log(JSON.stringify(result, null, 2))
   } catch (error:any) {
	console.error(error.message)
   } finally {
       await orm.end()
   }
})()

Result:

[
  {
    "id": 102,
    "customerId": "SPLIR",
    "employeeId": 7,
    "orderDate": "1996-11-07T23:00:00.000Z",
    "requiredDate": "1996-12-05T23:00:00.000Z",
    "shippedDate": "1996-11-14T23:00:00.000Z",
    "shipViaId": 1,
    "freight": 8.63,
    "name": "Split Rail Beer & Ale",
    "address": "P.O. Box 555",
    "city": "Lander",
    "region": "WY",
    "postalCode": "82520",
    "country": "USA",
    "customer": {
      "name": "Split Rail Beer & Ale"
    },
    "details": [
      {
        "quantity": 24,
        "unitPrice": 5.9,
        "product": {
          "name": "Tourtire",
          "category": {
            "name": "Meat/Poultry"
          }
        }
      }
    ]
  }
]

more info: include

Schema Configuration

Through the schema, you can define entities, enumerations, indexes, unique keys, default values, constraints, mapping, sources, stages, listeners, etc. The schema can be defined in a JSON or YAML format. Conditions or actions are performed using the same expression language that is used to define queries.

view: schema | definition | use | expressions | environment Variables | composite | listener | multiple stages | multiple sources | push | pull | fetch | introspect | incorporate

Features

Contributing

Would you like to contribute? Read our contribution guidelines to learn more. There are many ways to help!

Documentation

Full documentation is available in the Wiki.

All Labs

You can access various labs at lambdaorm labs

Related projects