Skip to content

JohnField/fortune-mysql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fortune MySQL Adapter

Build Status npm Version License

This is a MySQL adapter for Fortune; forked from the Postgres adapter as suggested in Fortune Issue 103.

DO NOT USE YET. Most functionality is broken due to differences between Postgres and MySQL. This includes:

  • auto-generation of schema
  • Column datatypes, defintions, etc.
  • CRUD
  • relationships
  • other differences yet to be discovered by testing

Usage

Install the fortune-mysql package from npm:

$ npm install fortune-mysql

Then use it with Fortune (db must be already available):

const fortune = require('fortune')
const mysqlAdapter = require('fortune-mysql')

const store = fortune({ ... }, {
  adapter: [
    mysqlAdapter,
    {
      // options object, URL is mandatory.
      url: `mysql://${username}:${password}@${host}:${port}/${db}`
    }
  ]
})

Options

  • url: Connection URL string. Required if no other connection options are given. Add the query param ssl=true to enable SSL.
  • connection: Connection object, see documentation. This takes precendence over the URL. Optional.
  • pool: an instance of a pool can be passed in directly. This takes precendence over all connection settings. Optional.
  • typeMap: an object keyed by type name and valued by table name.
  • primaryKeyType: Data type of the primary key. May be String, Number, or a string for custom type. Default: String.
  • generatePrimaryKey: A function that accepts one argument, the type of the record, and returns either a String or Number. By default, it returns 15 random bytes, base64 encoded in a URI-safe way. Set this to a falsey value like null to turn this off.
  • useForeignKeys: Whether or not to use foreign key constraint, optional since it will only be applied to non-array fields. Default: false.

For further options and internal usage, refer to the Postgres adapter.

License

This software is licensed under the MIT License.

About

MySQL adapter for Fortune.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%