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

ng-db-helper

v0.3.1

Published

Simple db helper for typescript like an orm with plugable connectors.

Downloads

18

Readme

NgDbHelperModule

This module is an ORM with plugable connector to share model and logic on multiple environnement.

This module simplify persistence with relationnal databases. As there is many platforms or devices, this module bring possibility to manage connectors. It allows integrators to have a better code portability.

It can be used with cordova-sqlite-storage, websql or other relationnal database if you implement your own connector.

See Usage documentation

See complete api documentation

See example project: Todos App

See examples of code below

Declaration:


@Table({name: 'todos'})
export class Todo extends DbHelperModel {

  @PrimaryKey({autoIncremented: true})
  public id: number;

  @Column()
  public name: string;

  @Column(type: 'number')
  public dueDate: number;

  @Column(type: 'boolean')
  public isDone: boolean;

  @ForeignModel(Category)
  public category: Category;
}

Use in a component:


@Component({
  selector: 'mgto-todos',
  template: '',
  styles: ''
})
class TodosPage implements OnInit {
  public todoQueryResult: QueryResult<Todo>;

  public ngOnInit() {
    // retrieve not done and not passed todos, you may put this in a service
    Select(Todo).where({isDone: false, and__dueDate__lt: (new Date()).getTime()}).exec()
      .subscribe((qr: QueryResult<Todo>) => {
        this.todoQueryResult = qr;
      }, (err) => {
        // manage error
      });
  }

  public checkTodo(todo: Todo) {
    todo.isDone = !todo.isDone;
    todo.save().subscribe(() => {
      // isDone did change and is saved
    }, (err) => {
      // manage error
      // cancel done change
      todo.isDone = !todo.isDone;
    });
  }
}

Prerequisites

Your application must be an angular project. Then choose the kind of database supported by the target device of your app. This module support can be configured to support Websql or cordova-sqlite-storage or both on specific conditions.

If you have other need and this need is to use a relationnal database, see the connector API and you will be able to build your own connector and keep using this API design.

Installing

This module is available on official npm registry, with command line from your project, use the command below:


npm install ng-db-helper --save

The module is now a part of your dependancies and is ready to be used. See Usage to learn about how easy it is !

Done and Todos

Contact me to suggest missing things on this todo list!

  • [ ] Queries
    • [x] select
    • [x] insert
    • [x] update
    • [x] delete
    • [ ] Manage join tables
    • [x] Sub queries management to clauses
    • [x] Sub clause group
    • [x] Composite clause to compaire tuple of column with tuple of values
    • [x] Allow semantic clause complexity
    • [x] Batch queries
  • [ ] Models
    • [x] Table annotation
    • [x] Column annotation
    • [x] Foreign models
    • [ ] Add foreign delete constraint
    • [ ] Many to many link
    • [ ] Manage more types like Date
    • [ ] add formatter functions
    • [ ] constraint management
    • [ ] Create a base service with usefull generic functions
    • [ ] Observe model change
  • [ ] Connectors
    • [x] standard interface
    • [x] plugable connector on init config
    • [x] cordova-sqlite-storage connector
    • [x] Websql connector
    • [x] Hybrid connector detecting cordova-sqlite-storage or Websql connector support and activate it
    • [x] Batch queries
    • [ ] Default connector configuration
  • [ ] Design
    • [ ] Pass some possible values for field to enum

Authors

  • Olivier Margarit

License

This project is licensed under the MIT License - see LICENSE file for details.