mongolike icon indicating copy to clipboard operation
mongolike copied to clipboard

test [sql/103-find4.sql]

Open JerrySievert opened this issue 11 years ago • 0 comments

filename : sql/103-find4.sql line # : 1 tag : todo md5 : 81d4d9a7c4e910db09b480a268d7eb18

--- [todo] - test
CREATE OR REPLACE FUNCTION find (collection varchar, terms json, lim int, skip int) RETURNS
SETOF json AS $$
  var table = 'col_' + collection;
  var sql = "SELECT data FROM " + table;

  var where_clause = plv8.find_function("where_clause");
  var where = where_clause(terms);
  where = JSON.parse(where);

  sql += " " + where.sql;
  if (lim > -1 ) {
    sql += "LIMIT " + lim;
  }

  if (skip > 0) {
    sql += "OFFSET " + skip;

JerrySievert avatar Feb 04 '14 04:02 JerrySievert