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

node-data-mapper

v1.1.27

Published

An object-relational mapper for node.js using the data mapper pattern.

Downloads

95

Readme

Build Status Coverage Status

node-data-mapper

node-data-mapper in object-relational mapper for Node.js. It uses the data-mapper pattern.

What does it do?

It takes queries that look like this:

SELECT  bs.bikeShopID, bs.name, bs.address,
        s.staffID, s.firstName, s.lastName
FROM    bike_shops bs
INNER JOIN staff s ON bs.bikeShopID = s.bikeShopID
ORDER BY bs.name, s.firstName

and makes them look like this:

dataContext
  .from('bike_shops bs')
  .innerJoin('bs.staff s')
  .select(
    'bs.bikeShopID', 'bs.name', 'bs.address',
    's.staffID', 's.firstName', 's.lastName')
  .orderBy('bs.name', 's.firstName')

It maps relational, tabular data that look like this:

bikeShopID|name|address|staffID|firstName|lastName ---|---|---|---|---|--- 1|Bob's Bikes|9107 Sunrise Blvd|2|John|Stovall 1|Bob's Bikes|9107 Sunrise Blvd|1|Randy|Alamedo 1|Bob's Bikes|9107 Sunrise Blvd|3|Tina|Beckenworth 3|Cycle Works|3100 La Riviera Wy|7|Kimberly|Fenters 3|Cycle Works|3100 La Riviera Wy|8|Michael|Xavier 3|Cycle Works|3100 La Riviera Wy|5|Sal|Green 3|Cycle Works|3100 La Riviera Wy|6|Valerie|Stocking 2|Zephyr Cove Cruisers|18271 Highway 50|4|Abe|Django

to a normalized document like this:

[ { bikeShopID: 1,
    name: 'Bob\'s Bikes',
    address: '9107 Sunrise Blvd',
    staff: 
     [ { staffID: 2, firstName: 'John', lastName: 'Stovall' },
       { staffID: 1, firstName: 'Randy', lastName: 'Alamedo' },
       { staffID: 3, firstName: 'Tina', lastName: 'Beckenworth' } ] },
  { bikeShopID: 3,
    name: 'Cycle Works',
    address: '3100 La Riviera Wy',
    staff: 
     [ { staffID: 7, firstName: 'Kimberly', lastName: 'Fenters' },
       { staffID: 8, firstName: 'Michael', lastName: 'Xavier' },
       { staffID: 5, firstName: 'Sal', lastName: 'Green' },
       { staffID: 6, firstName: 'Valerie', lastName: 'Stocking' } ] },
  { bikeShopID: 2,
    name: 'Zephyr Cove Cruisers',
    address: '18271 Highway 50',
    staff: [ { staffID: 4, firstName: 'Abe', lastName: 'Django' } ] } ]
Why should I use it?
  • It's fast.
  • The code is well documented and thoroughly tested.
  • Tutorials and documentation help you to get started quickly.
  • It works well with existing projects and databases.
  • The query interface is intuitive and closely resembles SQL.
  • Unlike other ORMs, there's no need to define models.
  • Queries use plain ol' JavaScript objects and arrays.
  • Security concerns like SQL injection are covered.
  • CRUD operations can be reused. Create a select query, and use the same query for updates and deletes.
  • It lets you easily create queries that can be filtered and ordered dynamically.
  • There are hooks for global conversions and transformations, like normalizing dates and formatting phone numbers.
  • Database modifications show up immediately. If you add a column to the database, you don't have to change any code.
  • It eliminates incosistent property names, which is a common problem in APIs.
How do I get started?

Go check out the tutorials!

Table of Contents