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

feathers-waterline-aggregate

v0.4.2

Published

A Waterline ORM service adapter. Provides support for aggregate sql functions.

Downloads

14

Readme

feathers-waterline-aggregate-aggregate

Greenkeeper badge Maintenance

Build Status Code Climate Test Coverage Dependency Status Download Status Slack Status

A database adapter for the Waterline ORM, the ORM used by SailsJS. For detailed Waterline documentation, see the waterline-docs repository. Currently Waterline supports the following data stores:

NOTE: Work In Progress. This fork intends to provide some aggregate function support not found in feathers-waterline.

Status

This module will continue to work as is but needs a maintainer for future feature and dependency updates. Create an issue if you are interested.

Installation

npm install feathers-waterline-aggregate --save

ProTip: You also need to install the waterline database adapter for the DB you want to use.

Getting Started

feathers-waterline-aggregate hooks a Waterline Model up to a configured data store as a feathers service.

const Message = require('./models/message');
const config = require('./config/waterline');
const Waterline = require('waterline');
const service = require('feathers-waterline-aggregate');

const ORM = new Waterline();

ORM.loadCollection(Message);
ORM.initialize(config, function(error, data) {
    app.use('/messages', waterlineService({
      Model: data.collections.message
    }));
});

Options

Creating a new Waterline service currently offers the following options:

  • Model (required) - The Waterline model definition
  • id (default: id) [optional] - The name of the id property
  • paginate [optional] - A pagination object containing a default and max page size (see the Pagination chapter)

Complete Example

Here is an example of a Feathers server with a messages Waterline Model using the Disk store:

$ npm install feathers feathers-rest feathers-socketio body-parser waterline sails-disk feathers-waterline-aggregate
const feathers = require('feathers');
const rest = require('feathers-rest');
const socketio = require('feathers-socketio');
const bodyParser = require('body-parser');
const Waterline = require('waterline');
const diskAdapter = require('sails-disk');
const service = require('feathers-waterline-aggregate');

const ORM = new Waterline();
const config = {
  adapters: {
    'default': diskAdapter,
    disk: diskAdapter
  },
  connections: {
    myLocalDisk: {
      adapter: 'disk'
    }
  },
  defaults: {
    migrate: 'alter'
  }
};
const Message = Waterline.Collection.extend({
  identity: 'message',
  schema: true,
  connection: 'myLocalDisk',
  attributes: {
    text: {
      type: 'string',
      required: true
    },

    complete: {
      type: 'boolean'
    }
  }
});

// Create a feathers instance.
const app = feathers()
  // Enable REST services
  .configure(rest())
  // Enable Socket.io services
  .configure(socketio())
  // Turn on JSON parser for REST services
  .use(bodyParser.json())
  // Turn on URL-encoded parser for REST services
  .use(bodyParser.urlencoded({ extended: true }));

ORM.loadCollection(Message);
ORM.initialize(config, (error, data) => {
  if (error) {
    console.error(error);
  }

  // Create a Waterline Feathers service with a default page size of 2 items
  // and a maximum size of 4
  app.use('/messages', service({
    Model: data.collections.message,
    paginate: {
      default: 2,
      max: 4
    }
  }));

  app.use(function(error, req, res, next){
    res.json(error);
  });
  
  // Create a dummy Message
  app.service('messages').create({
    text: 'Server message',
    complete: false
  }).then(function(message) {
    console.log('Created message', message.toJSON());
  });

  // Start the server
  const server = app.listen(3030);
  server.on('listening', function() {
    console.log('Feathers Message waterline service running on 127.0.0.1:3030');
    resolve(server);
  });
});

License

Copyright (c) 2016

Licensed under the MIT license.