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

@adocasts.com/generate-models

v0.1.0-4.dev

Published

Generate Lucid Models from an existing database schema

Downloads

240

Readme

@adocasts.com/generate-models

Generate Lucid Models from an existing database

npm-image license-image

Whether you're looking to start a new AdonisJS project for an existing database or you've define your migrations and ran them, this package can help you get up and running by generating models to match your database schema!

Note that this likely won't be perfect, always be sure to double-check the files after they're generated.

Here's how it works:

  1. It'll use AdonisJS to connect to your database
  2. Once connected, it collects your tables, columns, and foreign keys
  3. Then, it'll map out what your models should look like for the tables & columns
  4. Finally, it'll then use your foreign keys to work backwards and build out your relationships

Here's what's required:

  1. Your tables, columns, and foreign keys must be defined in your database
  2. Your database must be well structured, deviations will cause anomolies in the generated relationships
  3. Your AdonisJS application must have its database connection defined

Right now, we only have database type to TypeScript type mappings defined for MySQL and PostgreSQL. Unknown column types will default to unknown if they cannot be mapped.

Installation

You can easily install and configure via the Ace CLI's add command.

node ace add @adocasts.com/generate-models
Manual Install & Configure

You can also manually install and configure if you'd prefer

npm install @adocasts.com/generate-models
node ace configure @adocasts.com/generate-models

Generate Models Command

Right now we only offer one command, and that is the generate:models command.

node ace generate:models

This will generate your models and plop them at the location defined within your adonisrc.ts file, which is app/models by default. If any of the models already exist in your project, those models will be skipped and will not be replaced.