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

azure-odm

v0.0.1

Published

Lightweight ODM for Azure Table Storage Services, inspired by Mongoose

Readme

AzureODM-nodejs

Lightweight ODM for Azure Table Storage Services, inspired by Mongoose

Python Version: AzureODM-py

under development

Features

  • Mongoose like Entity and Model Definitions
  • Mongoose + Mongoengine like query styles
  • Field classes for easy validation and extension

Features under development

  • Update/Save entities
  • Remove azure-sdk-for-node dependency
  • Support dynamic tableName and query tableName as a field

Dependencies

Quick Guide

Define Model

var AzureODM = require('./AzureODM');
var Fields = AzureODM.Fields;

var PageSchema = AzureODM.Schema({
  RowKey: Fields.KeyField(), // hashed URL of the page
  PartitionKey: Fields.KeyField(), // netloc of the page, like example.com
  url: Fields.StringField(),
  title: Fields.StringField(),
  description: Fields.StringField(),
  pageType: Fields.StringField(),
  pageText: Fields.StringField(),
  summary: Fields.StringField(),
  author: Fields.StringField(),
  thumbnail: Fields.StringField(),
  publishedAt: Fields.DateTimeField(),
  updatedAt: Fields.DateTimeField(),
  createdAt: Fields.DateTimeField(),
  starCount: Fields.NumberField(),
  parserVersion: Fields.NumberField()
}, {
  tableName: 'pages',
  driver: new AzureODM.Driver(config.azure.storage.accountName,
    config.azure.storage.accountAccessKey)
});

// exports the compiled Page model
module.exports = AzureODM.Model.compile('Page', PageSchema);

Query

query begins with find()

var query = Page.find(QuerySet.object);

query will be a Query.QuerySet object with the Model Page attached

find by field

query.where({
        PartitionKey__eq: feedId
      });

or combine multiple queries for the same fields

query.where({
        PartitionKey__lt: `somethingLarge`,
        PartitionKey__gt: `somethingSmall`,
      });

query chain to query multiple fields

query.where({
        PartitionKey__eq: `something`
      })
     .orWhere({
        PartitionKey__eq: `somethingElse`
      })
     .andWhere({
        RowKey__eq: `somethingRow`
      });

limit the fields returned

query.select(['PartitionKey', 'RowKey', 'url', 'feedDesc', 'title', 'pubAt']);

limit the number of entities returned

query.limit(5);

exectute the query (will return a promise)

query.exec().then(function(pages){
    console.log(pages.length);
    });

Extend Model (before compile)


/**
 * get the page by partitionKey (netloc) and rowKey (hashedUrl)
 *
 * @method  getByHashedUrlsForNetloc
 *
 * @param   {String}                  netloc      PartitionKey, example.com
 * @param   {String}                  hashedUrls  RowKey, hashed url
 * @param   {Array}                  fields      a list of fields to be returned
 *
 * @return  {Page}                  Page Entity
 */
PageSchema.statics.getByHashedUrlsForNetloc = function (netloc, hashedUrls, fields) {
  return this.find().select(fields)
    .where({
      PartitionKey__eq: netloc
    })
    .andWhere({
      RowKey__in: hashedUrls
    })
    .exec();
};

/**
 * get a list of pages of urls
 *
 * @param  {Array}  urls
 * @param  {Function}     callback
 *
 * @return {[Page]}   return array of entites
 */
PageSchema.statics.getByUrls = function (urls) {
  var self = this;
  return new Promise(function (resolve, reject) {
    if (!Array.isArray(urls)) {
      return reject(new Error('urls is not an array'));
    }
    if (urls.length === 0) {
      return resolve([]);
    }

    var netlocAndHashedUrls = {}; // partition and row key pairs
   
    urls.forEach(function (url) {
      var PartitionKey = utils.netlocOfUrl(url);
      // hashUrl() returns hashed url 
      var RowKey = hashUrl(url);
      // netlocAndHashedUrls(url) returns netloc of the url
      if (!netlocAndHashedUrls.hasOwnProperty(PartitionKey)) {
        netlocAndHashedUrls[PartitionKey] = [RowKey];
      } else {
        netlocAndHashedUrls[PartitionKey].push(RowKey);
      }
    });
    // only return limitd set of fields
    var fields = ['PartitionKey',
      'RowKey',
      'url',
      'title',
      'description',
      'summary',
      'thumbnail',
      'parserVersion'
    ];

    // For async retrieving from Azure Table
    var ps = [];
    for (var pk in netlocAndHashedUrls) {
      if (netlocAndHashedUrls.hasOwnProperty(pk)) {
        ps.push(self.getByHashedUrlsForNetloc(
          pk, netlocAndHashedUrls[pk], fields));
      }
    }
    // using promise
    return resolve(Promise.all(ps).then(function (results) {
      var returnEntities = [];
      results.forEach(function (entities) {
        entities.forEach(function (entity) {
          returnEntities.push(entity);
        });
      });
      return returnEntities;
    }));
  });
};

Contributing

npm install

test: make test

Authors

Chen Liang

  • http://chen.technology
  • http://github.com/uschen

Credits

License

Licensed under the New BSD License