Skip to content

Latest commit

 

History

History
87 lines (70 loc) · 1.29 KB

ROADMAP.md

File metadata and controls

87 lines (70 loc) · 1.29 KB

Getting Started

Initiation

  1. Define basic connection settings in a config object
const config = {
    models: {
        directory: './models'
    },
    database: {
        name: 'postgres',
        dialect: 'postgres',
        connection: {
            host: 'localhost',
            port: 5432,
            username: 'postgres'
            password: '',
            database: 'dev',
            schema: 'public'
        }
    }
}

config API.

  1. Build your models (one model per file).
module.exports = {
	name: 'Post',
	properties: {
		title: {
			type: 'String',
			required: true
		},
		body: {
			type: 'String'
		},
		isPublished: {
			type: 'Boolean',
			required: true,
			defaultValue: false
		},
		author: {
			type: 'Reference',
			required: true,
			reference: 'Author',
			relation: 'many-to-one'
		},
		tags: {
			type: 'String',
			array: true
		}
	},
	options: {
		timestamps: true,
		shortid: true
	}
};

Models API

  1. Connect to database: returns a payload, including a Connection instance
import ormadillo from '@nuzu/ormadillo';
import config from './config.js';

const startServer = async () => {
    const {db} = await ormadillo(config);
}

startServer();

c

User -> index.js const library = require('ormadillo');