New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@wrserver/data

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wrserver/data

wrserver - data management module

latest
Source
npmnpm
Version
1.2.3
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 22 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts