koa-mongo-rest
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -10,3 +10,14 @@ var parse; | ||
try { | ||
result = yield model.find(this.request.query).exec(); | ||
var conditions = {}; | ||
var query = this.request.query; | ||
if (query.conditions) { | ||
conditions = JSON.parse(query.conditions); | ||
} | ||
var builder = model.find(conditions); | ||
['limit', 'skip', 'sort'].forEach(function(key){ | ||
if (query[key]) { | ||
builder[key](query[key]); | ||
} | ||
}) | ||
result = yield builder.exec(); | ||
return this.body = result; | ||
@@ -13,0 +24,0 @@ } catch (_error) { |
{ | ||
"name": "koa-mongo-rest", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "generate REST API with koa and mongo", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1,2 +0,2 @@ | ||
# Koa mongo REST [![NPM version](https://badge.fury.io/js/koa-mongo-rest.png)](http://badge.fury.io/js/koa-mongo-rest) [![Dependency Status](https://gemnasium.com/t3chnoboy/koa-mongo-rest.png)](https://gemnasium.com/t3chnoboy/koa-mongo-rest) [![Build Status](https://travis-ci.org/t3chnoboy/koa-mongo-rest.png?branch=master)](https://travis-ci.org/t3chnoboy/koa-mongo-rest) | ||
# Koa mongo REST [![NPM version](https://badge.fury.io/js/koa-mongo-rest.svg)](http://badge.fury.io/js/koa-mongo-rest) [![Dependency Status](https://gemnasium.com/t3chnoboy/koa-mongo-rest.svg)](https://gemnasium.com/t3chnoboy/koa-mongo-rest) [![Build Status](https://travis-ci.org/t3chnoboy/koa-mongo-rest.svg?branch=master)](https://travis-ci.org/t3chnoboy/koa-mongo-rest) | ||
@@ -3,0 +3,0 @@ Easy REST api for [koa](http://koajs.com) server |
49744
152