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

ember-parse-lib

v0.1.1

Published

The default blueprint for ember-cli addons.

Downloads

14

Readme

ember-parse-lib

NPM Ember Observer Score

An Ember addon to interact with Parse datastore.
This supports Ember API v2.x and above (built using Ember v2.8)
Also we have full support for custom Parse URLs including back4app or sashido or your very own Parse installation on your own DO/AWS/GC/Azure box.

Usage

Installation

Install the addon

ember install ember-parse-lib

Install [email protected] via Bower as frontend dependency

bower install parse@^1.9.2

In your config/environment.js add this to your ENV.APP

var ENV = {
  ...,
    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
      Parse: {
        url: 'https://parseapi.back4app.com',
        appId: 'G9h2udnUz5z2oVT7OAFNNSkcQKkORl6Sb2bePZ7B',
        jsApiId: 'MaVeTMJ0uubSRBADREgXy9UY98uPcxDRMEurTiyf'
      }
    }
  };

Saving Data

Create a model of your required class

ember g model fruit

You can make the model whichever way you want to, just like any simple Ember model

import DS from 'ember-data';

export default DS.Model.extend({
  color: DS.attr('string'),
  taste: DS.attr('string')
});

The modelName (which is just the file name of the model, all lowercase and dashified) of the model is used as class name in Parse.

If you want to have a custom class name (for eg, to have a capitalized name), reopen the class and add parseClass

import DS from 'ember-data';

export default DS.Model.extend({
  color: DS.attr('string'),
  taste: DS.attr('string')
}).reopenClass({
  parseClass: 'Fruit'
});

Save the data as you'd do with any Ember model

this.store.createRecord('fruit', {
  color: 'red',
  taste: 'sour'
}).save().then(function(savedObj) {
  console.log('Saved object with key ' + savedObj.id);
})

Fetching Data

To find all records in a class

this.store.findAll('fruits').then(function (fruits) {
    console.log(fruits);
    //Eat them fruits here ;)
  });

To find a particular entity by given id

    this.store.findRecord('fruits', '2D7dKQbCGZ').then(function(fruit) {
      console.log(fruit);
    });

Here we are fetching fruit with id = 2D7dKQbCGZ.

Queries

ember-parse-lib supports query constraints too. For example to find fruits in ascending order of their colour -

      this.store.query('fruits', {ascending: "colour"}).then(function (fruits) {
        console.log(fruits);
      });

And to find a particular username

      this.store.query('parseuser', {equalTo: {'username': username}}).then(function(users) {
        console.log(users);
      });

An example structure of your query filter object is this -

{
        equalTo: {
          city: "Delhi",
          country: "India"
        },
        notEqualTo: {
          gender: "male"
        },
        lessThan: {
          age: 40,
        },
        lessThanOrEqualTo: {
          hasCars: 4
        },
        greaterThan: {
          age: 20
        },
        greaterThanOrEqualTo: {
          kids: 1
        },
        ascending : ["age", "name"],
        descending: "city"
      }

This would find out people in Delhi, India, who are not males, between the age of 20 and 40, having less than 4 cars and more than 1 kid. It'll show up in ascending order of age, and within that, in order of name. Ties will be broken in descending order of city.

Signing up user

Sign up a user with username and password like this -

      let user = this.store.createRecord("parseuser");
      user.username = "username";
      user.password = "password";
      user.signUp().then((obj) => {
        console.log("Signed up user, and id of new user = " + obj.id);
      });

Logging in a user

Log in a user with username and password, or existing user object

      let user = this.store.createRecord("parseuser");
      user.username = username;
      user.password = password;
      user.logIn().then((obj) => {
        console.log("Parse object of user = " + obj);
      });
      obj.set("moredata", "somevalue");
      obj.save();

Contribution

Please read up on Ember's extending guidelines to get an idea of how Ember addons are structured.

Running

Running Tests

NOTE: I have not actually written any tests and writing tests for everything is something that needs to be done and is on high priority

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.