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

ngdatastore

v0.0.6

Published

Angular data objects

Readme

build status coverage report Commitizen friendly Sauce Test Status Dependency Status

Sauce Test Status

This is a Work In Progress project - do not use it until it reaches at least 0.1

ng2datastore : data access for angular2

This project is hosted on https://gitlab.com/solidev/ng2datastore Issues, builds and pull(merge) requests are on gitlab side, github repository is read-only.

Installation

Works with [email protected] / AOT "enabled" : npm install ng2datastore --save

Usage

With webpack : as is (see example); with systemjs : (see example)

map: { ... "ng2datastore": "./node_modules/ng2datastore",  ... },
packages: { "ng2datastore": { main: "index.js", defaultExtension: 'js' } ... }

No umd bundles are provided.

Example : default REST backend

This example uses the default REST setup :

  • REST api backend (GET/POST/PUT/PATCH/DELETE)
  • flat url adapter : urls in http://apiurl/item/{id} form
  • persistence backend : shared memory cache for objects
  • default serializer : removes all _ and $ prefixed properties of models
  • renderer and parser : json content-type, not wrapped
  • no pagination for list results

Models declaration

// file models/train.service.ts
// ----------------------------
import {DSModel, DSCollection, DSRestCollectionSetup} from "ng2datastore";
import {Injectable} from "@angular/core";

// Model declaration
export class Train extends DSModel {
    // Model fields
    public id: number;
    public title: string;
    // Model methods
    public honk(): void {
        console.log(`${this.title} is honking`);
    }
}

// Train collections provider
@Injectable()
export class TrainService extends DSCollection<Train> {
    public adapter_config = {basePath: "/trains"};
    public model = Train;
    // Needed to inject default settings
    constructor(public setup: DSRestCollectionSetup) {
        super(setup);
    }
}

Module and providers

// file app.module.ts
// ------------------
import {NgModule} from "@angular/core";

// import Rest module and config providers
import {RestModule, REST_ADAPTER_CONFIG} from "ng2datastore";

import {TrainService} from "models/train.service";

@NgModule({
    imports: [BrowserModule, RestModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
    providers: [
        // providing backend config
        {provide: REST_BACKEND_CONFIG, useValue: {url: "https://example.com/api/v1"}},
        // our train service
        TrainService]
})
export class AppModule {
}

Usage

  • inject TrainService
  • use directly TrainService to retrieve, create, update, delete model instances
  • use queryset to list, filter, paginate results
import {Component} from "@angular/core";
import {Train, TrainService} from "models/train.service";

@Component({
    selector: "my-train",
    template: `
    <h1>My train</h1>
    <div>{{train?.id}} {{train?.title}}</div>
    <ul>
        <li><a (click)="retrieveAction()">Retrieve</a></li>
        <li>...</li>
    </ul>
    `;
})
export class TrainComponent {
    public train: Train;
    public trains: Train[];

    constructor(private _trains: TrainService) {
    }

    public retrieveAction(): void {
        this._trains.get(1)
            .subscribe((t) => {
                console.log("Got train", t);
                this.train = t;
            })
    }

    public saveAction(): void {
        this.train.title = "Chugginton";
        this.train.save()
            .subscribe((t) => {
                console.log("Saved train", t, this.train);
            });
    }

    public createAction(): void {
        this._trains.save({title: "New train"})
            .subscribe((t) => {
                console.log("Created (but not saved) train", t);
                this.train = t;
            })
     }

    public createAndSaveAction(): void {
        this._trains.save({title: "New train"}, {create: true})
            .subscribe((t) => {
                console.log("Created and saved train", t);
                this.train = t;
            })

    }

    public getFromCacheAction(): void {
        this._trains.get(1, {fromcache: true})
            .subscribe((t) => {
                console.log("Got train without API call", t);
                this.train = t;
            })
    }

    public removeAction(): void {
        this._trains.remove()
            .subscribe(() => {
                console.log("Deleted train 1);
            })
    }

    public searchAction(): void {
        this._trains.queryset
            .filter({name: "chugginton"})
            .sort(["+name", "-id"])
            .paginate({page: 1, perpage: 10})
            .get()
            .subscribe((paginated) => {
                console.log("Pagination infos", paginated.pagination);
                this.trains = paginated.items;
            });
    }

}

Get it in action (TODO)

API

Model API

Details : see model

  • .save(): Observable(model)
  • .update(fields: string[]): Observable(model)
  • .remove(): Observable(any)
  • .refresh(): Observable(model)
  • .assign(data, options): DSValidationResult
    • options.validate: true|false
    • options.async: true|false)
  • .validate(options): DSValidationResult
    • options.async = true|false
  • .dirty(): string[]

Collection API

Details : see collection

  • constructor(setup, context)
  • init()

Model instance operations :

  • save(values, options): Observable(model)
    • options.validation = true|*false*|"sync"
    • options.save = true|*false*
    • options.volatile = true|*false*
  • save(model): Observable(model)
  • update(model, fields): Observable(model)
  • remove(model): Observable(any)
  • refresh(model)
  • get(pk, params): Observable(model)
    • params.fromcache = true|*false*
    • params.dual = true|*false*

Queryset :

  • queryset : return a new queryset instance.

Queryset API

TODO

Register API

TODO

Stack

Backend

See backend

Parser / renderer

See parser

See renderer

Serializer

See serializer

Adapter

See adapter

Persistence

See persistence

Paginator

TODO

Filters

TODO