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

@knestjs/core

v0.2.0-alpha

Published

Knestjs search to be a Nestjs ORM in which you write the models once and only once. This is done creating migrations automatically from the models that you create.

Downloads

15

Readme

Knestjs

Knestjs search to be a Nestjs ORM in which you write the models once and only once. This is done creating migrations automatically from the models that you create.

How to use it

  1. Register the core module in your app module like so:
@Module({
  imports: [
    KnestModule.forRoot({
         db: {
             client: 'sqlite3',
             connection: {
                 filename: ':memory:'
             },
             useNullAsDefault: true,
         },
         migrations: {
             folder: `${__dirname}/../../migrations`
         }
     }),
 ]
})
export class AppModule {}

This will configure knex with your db connection.

  1. Create some model:
@Table({
    tableName: 'user'
})
export class UserModel {
    @Column({
        type: 'int',
        autoincrement: true,
        nullable: false
    })
    id!: number

    @Column({
        type: 'varchar',
        length: 255,
        nullable: false
    })
    user!: string;
}

This will create a table with a column id, that is a number autoincrement, and a column user of type varchar.

  1. Register the models to your feature modules.

You can use the MigrationService to register the models, creating the TableSnapshotFactory with the module. But I recommend use a module like @knestjs/objection that uses Objection for providing the models, and also will provide you the tools to register the models easily.

How to handle the migrations?

Autogenerate migrations

You need to run the method makeMigrations from the MigrationService exported in @knestjs/core. You can use something like nestjs-command to provide a cli application for your project, you can use that cli application to run the migrations too.

How to run the migrations

The migrations are configured in knextjs by knestjs. You can retrieve the knextjs instance with the constant KNEX_INSTANCE from nestjs, and use the migrations API of knexjs.

Example

Take a look at the sample project cli module, that uses nestjs-command to provide a cli interface for the migrations