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

@wrserver/data

v1.2.3

Published

wrserver - data management module

Downloads

12

Readme

WRServer/Data

License Email Donate Donate

@wrserver data module, holding a new concept of Model as a Table, to interface json file as a db-like model.

Installing

Install this library is easy by cloning the repo. You can install trhought npm too:

Local installation

npm install @wrserver/data

Global installation

npm install -g @wrserver/data

We recomend to use the entire base package (core, crypt, data, auth, mail)

Data Model

This module add the DataModel to the WRServer Set of elements. The DataModel is usefull to manage files throught the DataService that allow to load/save json (encrypted or not) files.

Create a custom DataModel

import { Model, Column, Connection } from '@wrserver/core';
import { DataService, DataModel } from '@wrserver/data';

@Model
export class MyModel extends DataModel {
    //Use @Column.<TYPE>(defaultValue) for define a Db Column
    //Care that the defaultValue is evaluated once.
    //If it is an object reference every model will inherith the same reference.
    @Column.ID()
    public id: number;
    @Column.String()
    public stringType: string;
    @Column.Number(1)
    public numberType: number;
    @Column.Boolean(true)
    public booleanType: boolean;
    @Column.Array(()=>[0,1,2])
    public arrayType: number[];
    @Column.Date(()=>new Date())
    public dateType: Date;
    @Column.Model(MyModel2, () => new MyModel2(... params ...))
    public modelType: MyModel2;

    //NOT MAPPED PARAMETERS
    public otherParam1: boolean;
    public otherParam2: Date;

    public sendable(): any{ return { id: this.id, name: this.name, email: this.email, role: this.role }; }
}

DataService Usage

At Module defition

import { DataService, DataModule } from '@wrserver/data';

export class MyModule extends Module {
    //... controller, models, etc. ...
    public services: ServiceType[] = [ DataService, ... Other Services ... ];
    public dependencies: ModuleType[] = [ DataModule, ... Other Modules ... ];
    //... rest of code ...
}

At Server definition (settings)

import { WRServer }from '@wrserver/core';
import { DataModule } from '@wrserver/data';

//REMEMBER: don't use this static methods inside module definitions
DataModule.withDir(<directory>).withEncrypt(true|false)
            .withAlgorithm(<algorithm>).withCadence(<seconds autosave>)
            
//Server definition
let server: WRServer = new WRServer(...)

Contacts

If you like the project feel free to contact me on my Email.

Something gone wrong? Feel free to rise an issue!

Did you like this project and it was usefull? Help me improve my work:

Donate Donate