SQL to Waterline Model Generator

Convert SQL CREATE TABLE statements to Sails.js Waterline model definitions with proper type mapping, validations, and associations.

What is SQL to Waterline Model Generator?

This tool converts SQL CREATE TABLE statements to Sails.js Waterline model definitions. It generates proper attribute types, validations, associations for foreign keys, and lifecycle callback stubs.

How to Use

  1. Paste your SQL CREATE TABLE statements
  2. Select your database dialect
  3. Configure generation options (validations, callbacks, TypeScript)
  4. Click "Generate" and copy the Waterline models

Why Use This Tool?

Generate Sails.js Waterline model files instantly
Map SQL types to Waterline attribute types automatically
Convert foreign keys to Waterline associations
Generate validation rules from SQL constraints
Support PostgreSQL, MySQL, and SQLite dialects

Tips & Best Practices

  • Waterline uses the model name (singular, lowercase) as the identity by default
  • Foreign key columns ending in _id are converted to model associations
  • Use lifecycle callbacks to add custom logic before/after database operations
  • The customToJSON method lets you sanitize or transform records before sending to the client

Frequently Asked Questions

What is Waterline?

Waterline is the default ORM for Sails.js, a Node.js MVC framework. It provides a uniform API for accessing databases regardless of the underlying data store, supporting SQL databases, MongoDB, Redis, and more through adapters.

How are SQL types mapped to Waterline types?

SQL types are mapped to Waterline attribute types. INTEGER/BIGINT map to number, VARCHAR/TEXT map to string, BOOLEAN maps to boolean, TIMESTAMP/DATE map to ref (date), JSON/JSONB map to json, FLOAT/DOUBLE map to number, and UUID maps to string with uuid flag.

Does it generate Sails.js model files?

Yes, the tool generates Sails.js model files with the proper module.exports structure, including attributes with type definitions, validations, and association configurations.

How are foreign keys handled?

Foreign key references in SQL are converted to Waterline association attributes using model references. For example, author_id INTEGER REFERENCES users(id) becomes author: { model: "user" } in Waterline.

Is my SQL data sent to a server?

No, all processing happens entirely in your browser. Your SQL schema never leaves your device. The conversion is performed client-side using a regex-based parser.

Related Tools