33var _ = require ( 'lodash' ) ;
44var crypto = require ( 'crypto' ) ;
55var shiroTrie = require ( 'shiro-trie' ) ;
6- var ObjectID = require ( 'mongodb-legacy ' ) . ObjectId ;
6+ var ObjectID = require ( 'mongodb' ) . ObjectID ;
77
88var find_options = require ( '../server/query' ) ;
99
@@ -27,22 +27,22 @@ function init (env, ctx) {
2727 if ( ! Object . prototype . hasOwnProperty . call ( obj , 'created_at' ) ) {
2828 obj . created_at = ( new Date ( ) ) . toISOString ( ) ;
2929 }
30- collection . insertOne ( obj , function ( err , doc ) {
30+ collection . insert ( obj , function ( err , doc ) {
3131 if ( err != null && err . message ) {
3232 console . log ( 'Data insertion error' , err . message ) ;
3333 fn ( err . message , null ) ;
3434 return ;
3535 }
3636 storage . reload ( function loaded ( ) {
37- fn ( null , obj ) ;
37+ fn ( null , doc . ops ) ;
3838 } ) ;
3939 } ) ;
4040 }
4141 return doCreate ;
4242 }
4343
4444 function list ( collection ) {
45- function doList ( opts , fn ) {
45+ function doList ( opts , fn ) {
4646 // these functions, find, sort, and limit, are used to
4747 // dynamically configure the request, based on the options we've
4848 // been given
@@ -65,8 +65,6 @@ function init (env, ctx) {
6565 fn ( err , entries ) ;
6666 }
6767
68- console . log ( 'Loading' , opts ) ;
69-
7068 // now just stitch them all together
7169 limit . call ( collection
7270 . find ( query_for ( opts ) )
@@ -79,7 +77,7 @@ function init (env, ctx) {
7977
8078 function remove ( collection ) {
8179 function doRemove ( _id , callback ) {
82- collection . deleteOne ( { '_id' : new ObjectID ( _id ) } , function ( err ) {
80+ collection . remove ( { '_id' : new ObjectID ( _id ) } , function ( err ) {
8381 storage . reload ( function loaded ( ) {
8482 callback ( err , null ) ;
8583 } ) ;
@@ -94,7 +92,7 @@ function init (env, ctx) {
9492 if ( ! obj . created_at ) {
9593 obj . created_at = ( new Date ( ) ) . toISOString ( ) ;
9694 }
97- collection . insertOne ( obj , function ( err ) {
95+ collection . save ( obj , function ( err ) {
9896 //id should be added for new docs
9997 storage . reload ( function loaded ( ) {
10098 callback ( err , obj ) ;
@@ -137,14 +135,8 @@ function init (env, ctx) {
137135
138136 storage . reload = function reload ( callback ) {
139137
140- console . log ( 'Reloading auth data' ) ;
141-
142138 storage . listRoles ( { sort : { name : 1 } } , function listResults ( err , results ) {
143-
144- console . log ( 'Roles listed' ) ;
145-
146139 if ( err ) {
147- console . log ( 'Problem listing roles' , err ) ;
148140 return callback && callback ( err ) ;
149141 }
150142
@@ -160,7 +152,6 @@ function init (env, ctx) {
160152
161153 storage . listSubjects ( { sort : { name : 1 } } , function listResults ( err , results ) {
162154 if ( err ) {
163- console . log ( 'Problem listing subjects' , err ) ;
164155 return callback && callback ( err ) ;
165156 }
166157
0 commit comments