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

angularjs-mongolab

v1.0.0-RC1

Published

[![Build Status](https://secure.travis-ci.org/pkozlowski-opensource/angularjs-mongolab.png)](http://travis-ci.org/pkozlowski-opensource/angularjs-mongolab) [![devDependency Status](https://david-dm.org/pkozlowski-opensource/angularjs-mongolab/dev-status.p

Downloads

4

Readme

Build Status devDependency Status

Promise-aware MongoLab $resource-like adapter for AngularJS

Introduction

This repository hosts a Mongolab $resource-like adapter for AngularJS. It is based on $http and is working with promises.

This is a small wrapper around the AngularJS $http that makes setting up and working with MongoLab easy. It has an interface very similar to $resource but works with promises. It significantly reduces the amount of boilerplate code one needs to write when interacting with MongoDB / MongoLab (especially around URLs handling, resource objects creation and identifiers handling).

Examples

To see it in action check this plunker: (http://plnkr.co/edit/Bb8GSA?p=preview).

Usage instructions

Firstly you need to include both AngularJS and the angular-mongolab.js script [https://github.com/pkozlowski-opensource/angularjs-mongolab/blob/master/src/angular-mongolab.js](from this repository).

Then, you need to configure 2 parameters:

  • MongoLab key (API_KEY)
  • database name (DB_NAME)

Configuration parameters needs to be specified in a constant MONGOLAB_CONFIG on an application's module:

var app = angular.module('app', ['mongolabResourceHttp']);

app.constant('MONGOLAB_CONFIG',{API_KEY:'your key goes here', DB_NAME:'angularjs'});

Then, creating new resources is very, very easy and boils down to calling $mongolabResource with a MongoDB collection name:

app.factory('Project', function ($mongolabResourceHttp) {
    return $mongolabResourceHttp('projects');
});

As soon as the above is done you are ready to inject and use a freshly created resource in your services and controllers:

app.controller('AppController', function ($scope, Project) {
  Project.all().then(function(projects){
    $scope.projects = projects;
  });
});

Documentation

Since this $resource-like implementation is based on $http and returns a promise. Each resource created with the $mongolabResourceHttp will be equipped with the following methods:

  • on the class level:
    • Resource.all([options])
    • Resource.query(criteriaObject,[options])
    • Resource.getById(idString)
    • Resource.getByIds(idsArray)
    • Resource.count(criteriaObject)
    • Resource.distinct(fieldName, criteriaObject)
  • on an instance level:
    • resource.$id()
    • resource.$save()
    • resource.$update()
    • resource.$saveOrUpdate()
    • resource.$remove()

Resource all and query supported options:

  • sort: ex.: Resource.all({ sort: {priority: 1} });
  • limit: ex.: Resource.all({ limit: 10 });
  • fields: 1 - includes a field, 0 - excludes a field, ex.: Resource.all({ fields: {name: 1, notes: 0} });
  • skip: ex.: Resource.all({ skip: 10 });

Contributting

New contributions are always welcomed. Just open a pull request making sure that it contains tests, doc updates. Checked if the Travis-CI build is alright.

Contributtors

https://github.com/pkozlowski-opensource/angularjs-mongolab/graphs/contributors