https://github.com/filerjs/filer-sql
Support for MySQL, MariaDB, SQLite or PostgreSQL Filer providers
https://github.com/filerjs/filer-sql
Last synced: 4 months ago
JSON representation
Support for MySQL, MariaDB, SQLite or PostgreSQL Filer providers
- Host: GitHub
- URL: https://github.com/filerjs/filer-sql
- Owner: filerjs
- License: mpl-2.0
- Created: 2014-10-09T14:28:18.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-11-25T16:32:01.000Z (over 11 years ago)
- Last Synced: 2025-08-09T06:23:30.277Z (10 months ago)
- Language: JavaScript
- Size: 178 KB
- Stars: 2
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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:
```js
// 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](http://sequelizejs.com/docs/1.7.8/usage#options).
### Database Schema
The database will have a single table, named `filer_data` with the following columns:
|Name|Type |Details |
-----|----------------------|------------------------------------------------------------------|
|user|STRING(20) Primary Key|Unique username for this user's filesystem |
|key |STRING(36) Primary Key|Filer Node ID's of the form '00000000-0000-0000-0000-000000000000'|
|data|BLOB |binary data with JSON stored as Object->JSON->Buffer(utf8)) |