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

instant-crud

v1.0.14

Published

Package used to generate data models, interfaces, repositories.

Downloads

23

Readme

instant-crud

Package used to generate model, interface and repository code files of MongoDB (mongoose). Everything generated for coding with TypeScript.

Install

npm i instant-crud -g, for global ic usage.

Requirements

!IMPORTANT!

Before star using this tool - please copy files from ../node_modules/src/base/repositories into predefined directory, where your generated repositories will exist. Or do this after first migration.

To successfull use this package you should create 2 config-like JSON files:

  • Definitions config file, to define all data instances:
{
    ...
    "instance-name": {
        // *columns* - defines object model items and their types.
        "columns": [
            {
                "name": "col1",
                "type": "boolean"
                "required": true,
                "default": false
            },
            {
                "name": "col2",
                "type": "number"
            },
            {
                "name": "col3",
                "type": "array"
            },
            {
                "name": "col4",
                "type": "string"
            },
            ...
        ],
        // *visible_columns* - for defining public model instance methods (get/set). 
        "visible_columns": [
            "cover_picture",
            "user",
            "files",
            "comment",
            "likes"
        ],
        // *relations* - definitions of relations with other instances. Generates methods for auto-selecting related instance objects (records).
        // - table: related instance
        // - property: related instance item to relate
        // - item_field: current instance item to relate
        // - is_array: definition, if relation is array
        "relations": [
            {
                "table": "instance2",
                "property": "_id",
                "item_field": "col2",
                "is_array": false
            },
            ...
        ]
    }
  • Config file, to define MongoDB connections, file formatting settings:
    ...
    "mongo": {
        "server": "localhost",
        "port": null,
        "database": "database_of_project",
        "username": root,
        "password": null
    },
    "file_writer": {
        "tabs_size": 4,
        "output": {
            "interface": {
                "dir": "/core"
            },
            "repository": {
                "dir": "/core"
            },
            "model": {
                "dir": "/core"
            }
        }
    }
    ...

Usage

Commands:

Run ic migrate - migration command.

Run ic test-directory - command, to check if CLI correctly gets your project root directory.

migrate command options:

  • -m [migration] : define migration instance to be generated. If not defined, it will roll and generated all defined instance from definition config. Ex.: ic migrate -m instance-name ... or ic migrate -m ...

  • -d [definitions-config] : define path to JSON file, where is defined items, which has to be generated. Ex.: ic migrate -m -d config/definitions.json (!important: root directory of project will be automatically picked!)

  • -c [config] : define path to JSON file, where is defined items: mongo - with all connection properties & file_writer - for defining output directories and tabs size for formatting generating code. Ex.: ic migrate -m -d config/app.json (!important: root directory of project will be automatically picked!)