caminte
caminte copied to clipboard
MYSQL auto create
Hi,
I would like to know if there is any parameters that I have to add on the caminte constructor to auto create SQL Tables if they are not created?
Thank you.
@edeuxk did you figure this out?
figured it out.
var caminte = require('caminte');
var Schema = caminte.Schema;
config = {
driver : "mysql", // or mariadb
...........
};
var schema = new Schema(config.driver, config);
var Post = schema.define('Post', {
title: { type: schema.String, limit: 255 },
content: { type: schema.Text },
params: { type: schema.JSON },
date: { type: schema.Date, default: Date.now },
published: { type: schema.Boolean, default: false, index: true }
});
schema.adapter.automigrate(function() {
console.log('done auto migrating!!!');
});
if you want to update the schema without droping and creating a new table when you change fields, use:
schema.adapter.autoupdate(function() {})