This repository was archived by the owner on Nov 10, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +31
-3
lines changed
Expand file tree Collapse file tree 4 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ function createModel (requelize) {
185185 * @param {string } ModelA Model name
186186 * @param {string } ModelB Model name
187187 */
188- static customJoinTable ( ModelA , ModelB ) {
188+ static customJoinTable ( ModelA , ModelB ) {
189189 Model . index ( ModelA )
190190 Model . index ( ModelB )
191191 }
Original file line number Diff line number Diff line change @@ -31,7 +31,13 @@ class Query {
3131
3232 // enable model parsing for query result
3333 if ( this . _parse ) {
34- q = q . then ( ( res ) => this . _Model . _parse ( res ) )
34+ q = q . then ( ( res ) => {
35+ if ( res ) {
36+ return this . _Model . _parse ( res )
37+ } else {
38+ return Promise . reject ( new RequelizeError ( 'DocumentNotFound' ) )
39+ }
40+ } )
3541 }
3642
3743 return q
Original file line number Diff line number Diff line change 11{
22 "name" : " requelize" ,
3- "version" : " 0.6.0 " ,
3+ "version" : " 0.6.1 " ,
44 "description" : " RethinkDB ORM" ,
55 "main" : " index.js" ,
66 "repository" : " https://github.com/buckless/requelize.git" ,
Original file line number Diff line number Diff line change 1+ const { test, requelize, dropDb } = require ( './utils' )
2+
3+ test ( 'document not found error' , ( t ) => {
4+ t . plan ( 2 )
5+
6+ let Foo
7+
8+ dropDb ( )
9+ . then ( ( ) => {
10+ Foo = requelize . model ( 'foo' )
11+
12+ return requelize . sync ( )
13+ } )
14+ . then ( ( ) => {
15+ return Foo . get ( 'foo' ) . run ( )
16+ } )
17+ . catch ( ( err ) => {
18+ t . equal ( 'RequelizeError' , err . name )
19+ t . equal ( 'DocumentNotFound' , err . message )
20+ t . end ( )
21+ } )
22+ } )
You can’t perform that action at this time.
0 commit comments