Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

schema-typegen

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

schema-typegen - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

schema-typegen.d.ts

3

package.json
{
"name": "schema-typegen",
"version": "2.4.0",
"version": "2.5.0",
"description": "Generate TypeScript type definitions from database schema",
"main": "schema-typegen.js",
"types": "schema-typegen.d.ts",
"bin": {

@@ -7,0 +8,0 @@ "schema-typegen": "schema-typegen.js"

@@ -99,2 +99,13 @@ <h1 align="center">Welcome to schema-typegen 👋</h1>

### Running from code
```ts
import { join } from 'path'
import generate from 'schema-typegen'
;(async () => {
const output = join(__dirname, 'entities.ts')
await generate({ connection: 'postgres://username:password@localhost:5432/database', output })
})()
```
### Loading database config

@@ -101,0 +112,0 @@

@@ -63,2 +63,14 @@ #! /usr/bin/env node

async function generateSchema (opts) {
opts = { ...defaultOpts, exclude: [], ...opts }
const schema = await postgres(opts)
const types = await typescript(opts, schema)
if (opts.output) {
fs.writeFileSync(opts.output, types)
return `✔ Generated types from ${schema.tables.length} tables and ${schema.enums.length} enums`
} else {
return types
}
}
if (require.main === module) {

@@ -73,16 +85,7 @@ (async () => {

const schema = await postgres(opts)
const types = await typescript(opts, schema)
if (opts.output) {
fs.writeFileSync(opts.output, types)
console.log(`✔ Generated types from ${schema.tables.length} tables and ${schema.enums.length} enums`)
} else {
console.log(types)
}
const result = await generateSchema(opts)
console.log(result)
})()
}
module.exports = {
typescript,
postgres
}
module.exports = generateSchema
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc