@@ -25,7 +25,7 @@ function handleError(res, statusCode) {
2525 * restriction: 'admin'
2626 */
2727export function index ( req , res ) {
28- < % if ( filters . mongooseModels ) { % > User . findAsync ( { } , '-salt -password' ) < % }
28+ < % if ( filters . mongooseModels ) { % > User . find ( { } , '-salt -password' ) . exec ( ) < % }
2929 if ( filters . sequelizeModels ) { % > User . findAll ( {
3030 attributes : [
3131 '_id' ,
@@ -48,13 +48,12 @@ export function create(req, res, next) {
4848 < % if ( filters . mongooseModels ) { % > var newUser = new User ( req . body ) ;
4949 newUser . provider = 'local' ;
5050 newUser . role = 'user' ;
51- newUser . saveAsync ( ) < % }
51+ newUser . save ( ) < % }
5252 if ( filters . sequelizeModels ) { % > var newUser = User . build ( req . body ) ;
5353 newUser . setDataValue ( 'provider' , 'local' ) ;
5454 newUser . setDataValue ( 'role' , 'user' ) ;
5555 newUser . save ( ) < % } % >
56- < % if ( filters . mongooseModels ) { % > . spread ( function ( user ) { < % }
57- if ( filters . sequelizeModels ) { % > . then ( function ( user ) { < % } % >
56+ . then ( function ( user ) {
5857 var token = jwt . sign ( { _id : user . _id } , config . secrets . session , {
5958 expiresIn : 60 * 60 * 5
6059 } ) ;
@@ -69,7 +68,7 @@ export function create(req, res, next) {
6968export function show ( req , res , next ) {
7069 var userId = req . params . id ;
7170
72- < % if ( filters . mongooseModels ) { % > User . findByIdAsync ( userId ) < % }
71+ < % if ( filters . mongooseModels ) { % > User . findById ( userId ) . exec ( ) < % }
7372 if ( filters . sequelizeModels ) { % > User . find ( {
7473 where : {
7574 _id : userId
@@ -89,7 +88,7 @@ export function show(req, res, next) {
8988 * restriction: 'admin'
9089 */
9190export function destroy ( req , res ) {
92- < % if ( filters . mongooseModels ) { % > User . findByIdAndRemoveAsync ( req . params . id ) < % }
91+ < % if ( filters . mongooseModels ) { % > User . findByIdAndRemove ( req . params . id ) . exec ( ) < % }
9392 if ( filters . sequelizeModels ) { % > User . destroy ( { _id : req . params . id } ) < % } % >
9493 . then ( function ( ) {
9594 res . status ( 204 ) . end ( ) ;
@@ -105,7 +104,7 @@ export function changePassword(req, res, next) {
105104 var oldPass = String ( req . body . oldPassword ) ;
106105 var newPass = String ( req . body . newPassword ) ;
107106
108- < % if ( filters . mongooseModels ) { % > User . findByIdAsync ( userId ) < % }
107+ < % if ( filters . mongooseModels ) { % > User . findById ( userId ) . exec ( ) < % }
109108 if ( filters . sequelizeModels ) { % > User . find ( {
110109 where : {
111110 _id : userId
@@ -114,8 +113,7 @@ export function changePassword(req, res, next) {
114113 . then ( user => {
115114 if ( user . authenticate ( oldPass ) ) {
116115 user . password = newPass ;
117- < % if ( filters . mongooseModels ) { % > return user . saveAsync ( ) < % }
118- if ( filters . sequelizeModels ) { % > return user . save ( ) < % } % >
116+ return user . save ( )
119117 . then ( ( ) => {
120118 res . status ( 204 ) . end ( ) ;
121119 } )
@@ -132,7 +130,7 @@ export function changePassword(req, res, next) {
132130export function me ( req , res , next ) {
133131 var userId = req . user . _id ;
134132
135- < % if ( filters . mongooseModels ) { % > User . findOneAsync ( { _id : userId } , '-salt -password' ) < % }
133+ < % if ( filters . mongooseModels ) { % > User . findOne ( { _id : userId } , '-salt -password' ) . exec ( ) < % }
136134 if ( filters . sequelizeModels ) { % > User . find ( {
137135 where : {
138136 _id : userId
0 commit comments