PostgreSQL adapter for JugglingDB
PostgreSQL adapter for JugglingDB.
To use it you need
Setup dependencies in
Use:var Schema = require'jugglingdb'Schema;var schema = 'postgres'database: 'myapp_test'username: 'postgres'// host: 'localhost',// port: 5432,// password: s.password,// database: s.database,// ssl: true,// debug: false;
- Support for
floatdatatypes, ala the mysql adapter. Just add
dataType: 'float'to your column properties:
var Model = schemadefine'Model'realNumber: type: Number dataType: 'float';
- Support for single and multi-column indexes, ala the mysql adapter. Single column indexes are specified by adding
index: trueto the column properties. Unique single-column indexes are created by adding
unique: trueto the column properties (it is unnecessary to also specify
index: truesince it is implied). Multi-column indexes are added by specifying
indexesin the settings hash of the
schema.definemethod. Single-column indexes may also be specified this way if you want to have a little more control over their options. Each key in the
indexeshash is the name of the index, and the value is a hash which specifies the index properties:
var Model = schemadefine'Model'column1: type: Number index: truecolumn2: type: Numberindexes:indexName1:columns: 'column1, column2'type: 'btree';
The full list of supported index properties are:
columns: 'comma, delimited, list, of, columns'keys: 'array' 'of' 'columns' // takes precedence over "columns"!type: 'TYPE' // 'btree', 'hash', etckind: 'KIND' // 'unique' is the only valid option
See the postgres documentation for more information about
- Support for arbitrary where clauses:
Modelallwhere: arbitrary: 'RANDOM STRING DOING ANYTHING';
You can still have columns named
arbitrary in your models; those will take precedence if found.
Note: This is a perfect moment to discuss the unwise nature of passing filter objects from the client to the server. Don't do it. Expose endpoints which then call
all() with known arguments.
- Support for an 'or' operator in where clauses. For example, you can look for models which either have a matching
userId, or the same
createddate greater than one day ago:
var where =or:userId: 5ip: reqipcreated:gt: oneDayAgoModelallwhere: where;
Similar to the arbitrary operator above, any column named
or in your model will take precedence if found.
Copyright (C) 2012 by Anatoliy Chakkaev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.