From 8d36a9b95eaab9c1c3a00aed43e0cbffa2436d35 Mon Sep 17 00:00:00 2001 From: Marcelo Gomes Barbosa Date: Tue, 23 Apr 2013 11:42:38 -0300 Subject: [PATCH] adding support to array usage: declaration: -- field: {type: Array, array:Number, default: null} property 'array' is the array type; add support to condition type 'any' -- where: {'field': {'any': 'x'}} --- lib/postgres.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/postgres.js b/lib/postgres.js index 59a96c5..5e3711c 100644 --- a/lib/postgres.js +++ b/lib/postgres.js @@ -284,6 +284,10 @@ PG.prototype.toFilter = function (model, filter) { fields.push(condType == 'inq' ? 'FALSE' : 'TRUE'); return true; } + if(condType == 'any') { + fields.push(' ' + filterValue + ' = ANY("' + key + '")'); + return true; + } switch (condType) { case 'gt': sqlCond += ' > '; @@ -619,6 +623,12 @@ function datatype(p) { return 'timestamp'; case 'Boolean': return 'boolean'; + case 'Array': + if(p.array && p.array.name === 'Number') { + return 'integer[]'; + } else { + return 'varchar[]'; + } } };