@@ -4,71 +4,71 @@ var common = require('../common');
44var ORM = require ( '../../' ) ;
55
66describe ( "custom types" , function ( ) {
7- if ( common . protocol ( ) == 'mongodb' ) return ;
7+ if ( common . protocol ( ) == 'mongodb' ) return ;
88
9- var db = null ;
10- var LottoTicket = null ;
9+ var db = null ;
10+ var LottoTicket = null ;
1111
12- var setup = function ( opts ) {
13- return function ( done ) {
14- db . defineType ( 'numberArray' , {
15- datastoreType : function ( prop ) {
16- return 'TEXT'
17- } ,
18- valueToProperty : function ( value , prop ) {
19- if ( Array . isArray ( value ) ) {
20- return value ;
21- } else {
22- return value . split ( ',' ) . map ( function ( v ) {
23- return Number ( v ) ;
24- } ) ;
25- }
26- } ,
27- propertyToValue : function ( value , prop ) {
28- return value . join ( ',' )
29- }
30- } ) ;
12+ var setup = function ( opts ) {
13+ return function ( done ) {
14+ db . defineType ( 'numberArray' , {
15+ datastoreType : function ( prop ) {
16+ return 'TEXT'
17+ } ,
18+ valueToProperty : function ( value , prop ) {
19+ if ( Array . isArray ( value ) ) {
20+ return value ;
21+ } else {
22+ return value . split ( ',' ) . map ( function ( v ) {
23+ return Number ( v ) ;
24+ } ) ;
25+ }
26+ } ,
27+ propertyToValue : function ( value , prop ) {
28+ return value . join ( ',' )
29+ }
30+ } ) ;
3131
32- LottoTicket = db . define ( 'lotto_ticket' , {
33- numbers : { type : 'numberArray' }
34- } ) ;
32+ LottoTicket = db . define ( 'lotto_ticket' , {
33+ numbers : { type : 'numberArray' }
34+ } ) ;
3535
36- return helper . dropSync ( LottoTicket , done ) ;
37- } ;
38- } ;
36+ return helper . dropSync ( LottoTicket , done ) ;
37+ } ;
38+ } ;
3939
40- before ( function ( done ) {
41- helper . connect ( function ( connection ) {
42- db = connection ;
40+ before ( function ( done ) {
41+ helper . connect ( function ( connection ) {
42+ db = connection ;
4343
44- return done ( ) ;
45- } ) ;
46- } ) ;
44+ return done ( ) ;
45+ } ) ;
46+ } ) ;
4747
48- after ( function ( ) {
49- db . close ( ) ;
50- } ) ;
48+ after ( function ( ) {
49+ db . close ( ) ;
50+ } ) ;
5151
52- it ( "should create the table" , function ( done ) {
53- setup ( ) ( done ) ;
54- } ) ;
52+ it ( "should create the table" , function ( done ) {
53+ setup ( ) ( done ) ;
54+ } ) ;
5555
56- it ( "should store data in the table" , function ( done ) {
57- var ticket = new LottoTicket ( { numbers : [ 4 , 23 , 6 , 45 , 9 , 12 , 3 , 29 ] } ) ;
56+ it ( "should store data in the table" , function ( done ) {
57+ var ticket = new LottoTicket ( { numbers : [ 4 , 23 , 6 , 45 , 9 , 12 , 3 , 29 ] } ) ;
5858
59- ticket . save ( function ( err ) {
60- should . not . exist ( err ) ;
59+ ticket . save ( function ( err ) {
60+ should . not . exist ( err ) ;
6161
62- LottoTicket . find ( ) . all ( function ( err , items ) {
63- should . not . exist ( err ) ;
64- should . equal ( items . length , 1 ) ;
65- should ( Array . isArray ( items [ 0 ] . numbers ) ) ;
62+ LottoTicket . find ( ) . all ( function ( err , items ) {
63+ should . not . exist ( err ) ;
64+ should . equal ( items . length , 1 ) ;
65+ should ( Array . isArray ( items [ 0 ] . numbers ) ) ;
6666
67- [ 4 , 23 , 6 , 45 , 9 , 12 , 3 , 29 ] . should . eql ( items [ 0 ] . numbers ) ;
67+ [ 4 , 23 , 6 , 45 , 9 , 12 , 3 , 29 ] . should . eql ( items [ 0 ] . numbers ) ;
6868
69- done ( ) ;
70- } ) ;
71- } ) ;
72- } ) ;
69+ done ( ) ;
70+ } ) ;
71+ } ) ;
72+ } ) ;
7373
7474} ) ;
0 commit comments