@@ -25,7 +25,7 @@ function handleError(res, statusCode) {
25
25
* restriction: 'admin'
26
26
*/
27
27
export function index ( req , res ) {
28
- < % if ( filters . mongooseModels ) { % > User . findAsync ( { } , '-salt -password' ) < % }
28
+ < % if ( filters . mongooseModels ) { % > User . find ( { } , '-salt -password' ) . exec ( ) < % }
29
29
if ( filters . sequelizeModels ) { % > User . findAll ( {
30
30
attributes : [
31
31
'_id' ,
@@ -48,13 +48,12 @@ export function create(req, res, next) {
48
48
< % if ( filters . mongooseModels ) { % > var newUser = new User ( req . body ) ;
49
49
newUser . provider = 'local' ;
50
50
newUser . role = 'user' ;
51
- newUser . saveAsync ( ) < % }
51
+ newUser . save ( ) < % }
52
52
if ( filters . sequelizeModels ) { % > var newUser = User . build ( req . body ) ;
53
53
newUser . setDataValue ( 'provider' , 'local' ) ;
54
54
newUser . setDataValue ( 'role' , 'user' ) ;
55
55
newUser . save ( ) < % } % >
56
- < % if ( filters . mongooseModels ) { % > . spread ( function ( user ) { < % }
57
- if ( filters . sequelizeModels ) { % > . then ( function ( user ) { < % } % >
56
+ . then ( function ( user ) {
58
57
var token = jwt . sign ( { _id : user . _id } , config . secrets . session , {
59
58
expiresIn : 60 * 60 * 5
60
59
} ) ;
@@ -69,7 +68,7 @@ export function create(req, res, next) {
69
68
export function show ( req , res , next ) {
70
69
var userId = req . params . id ;
71
70
72
- < % if ( filters . mongooseModels ) { % > User . findByIdAsync ( userId ) < % }
71
+ < % if ( filters . mongooseModels ) { % > User . findById ( userId ) . exec ( ) < % }
73
72
if ( filters . sequelizeModels ) { % > User . find ( {
74
73
where : {
75
74
_id : userId
@@ -89,7 +88,7 @@ export function show(req, res, next) {
89
88
* restriction: 'admin'
90
89
*/
91
90
export function destroy ( req , res ) {
92
- < % if ( filters . mongooseModels ) { % > User . findByIdAndRemoveAsync ( req . params . id ) < % }
91
+ < % if ( filters . mongooseModels ) { % > User . findByIdAndRemove ( req . params . id ) . exec ( ) < % }
93
92
if ( filters . sequelizeModels ) { % > User . destroy ( { _id : req . params . id } ) < % } % >
94
93
. then ( function ( ) {
95
94
res . status ( 204 ) . end ( ) ;
@@ -105,7 +104,7 @@ export function changePassword(req, res, next) {
105
104
var oldPass = String ( req . body . oldPassword ) ;
106
105
var newPass = String ( req . body . newPassword ) ;
107
106
108
- < % if ( filters . mongooseModels ) { % > User . findByIdAsync ( userId ) < % }
107
+ < % if ( filters . mongooseModels ) { % > User . findById ( userId ) . exec ( ) < % }
109
108
if ( filters . sequelizeModels ) { % > User . find ( {
110
109
where : {
111
110
_id : userId
@@ -114,8 +113,7 @@ export function changePassword(req, res, next) {
114
113
. then ( user => {
115
114
if ( user . authenticate ( oldPass ) ) {
116
115
user . password = newPass ;
117
- < % if ( filters . mongooseModels ) { % > return user . saveAsync ( ) < % }
118
- if ( filters . sequelizeModels ) { % > return user . save ( ) < % } % >
116
+ return user . save ( )
119
117
. then ( ( ) => {
120
118
res . status ( 204 ) . end ( ) ;
121
119
} )
@@ -132,7 +130,7 @@ export function changePassword(req, res, next) {
132
130
export function me ( req , res , next ) {
133
131
var userId = req . user . _id ;
134
132
135
- < % if ( filters . mongooseModels ) { % > User . findOneAsync ( { _id : userId } , '-salt -password' ) < % }
133
+ < % if ( filters . mongooseModels ) { % > User . findOne ( { _id : userId } , '-salt -password' ) . exec ( ) < % }
136
134
if ( filters . sequelizeModels ) { % > User . find ( {
137
135
where : {
138
136
_id : userId
0 commit comments