0.0.3 • Published 9 years ago

filer-sql v0.0.3

Weekly downloads
2
License
MPL2.0
Repository
github
Last release
9 years ago

filer-sql

Support for MySQL, MariaDB, SQLite or PostgreSQL Filer providers.

Usage

The SQLProvider can be used with Filer on node.js (i.e., this won't work in browser) like so:

// Option 1 - connecting with a connection URL
var provider1 = new SQLProvider({
  // The db type to use, see below for other options
  type: SQLProvider.MYSQL,

  // A MySQL connection string
  url: 'mysql://user:pass@example.com:9821/dbname',

  // A unique string to identify this user's filesystem (e.g., username)
  user: 'something-unique'
});

// Option 2 - connecting with separate db options
var provider2 = new SQLProvider({
  // The db type to use, see below for other options
  type: SQLProvider.MYSQL,

  // If you want SQL debug logging, pass a logging function
  //logging: console.log,

  // A unique string to identify this user's filesystem (e.g., username)
  user: 'something-unique',

  // Database options
  db: {
    // Name of Database to use, defaults to 'filer'
    name: "name",
    // DB authentication info, if necessary
    username: "username",
    password: "password"
  }
});

var fs = new Filer.FileSystem({provider: provider2});

Database Types

The type of database can be one of:

  • SQLProvider.MYSQL
  • SQLProvider.SQLITE
  • SQLProvider.POSTGRES
  • SQLProvider.MARIADB

NOTE: some database types require you to pre-create your database. The default database name is filer unless you specify something else.

Database Options

If you want to pass extra options to Sequelize, add them to the options object. See the list of valid options.

Database Schema

The database will have a single table, named filer_data with the following columns:

NameTypeDetails
userSTRING(20) Primary KeyUnique username for this user's filesystem
keySTRING(36) Primary KeyFiler Node ID's of the form '00000000-0000-0000-0000-000000000000'
dataBLOBbinary data with JSON stored as Object->JSON->Buffer(utf8))