Ookma-Kyi
08/23/2022, 6:46 PMField 'username' doesn't have a default value
This is the code I am using.
// create Action
function create( event, rc, prc ){
...
var token = generateRandomToken();
var now = Now();
var expiration =DateAdd("d", 1, now);
var user = getInstance( "User" )
.firstWhere( "email", rc.email )
if( !isNull( user ) ) {
user.setToken( token )
.setExpiration( expiration )
.save();
}
relocate( uri = "/login" );
}
I don't see what that has to do with what I'm trying to do.bdw429s
08/23/2022, 6:48 PMOokma-Kyi
08/23/2022, 6:49 PMError Details
Error Code ---
Type database
Message Field 'username' doesn't have a default value
Detail ---
Extended Info ---
Environment development
Event forgotpassword.create
Route forgotpassword/
Route Name /forgotpassword
Routed Module ---
Routed Namespace ---
Routed URL forgotpassword/
Layout ---
Module ---
View ---
bdw429s
08/23/2022, 6:51 PMbdw429s
08/23/2022, 6:51 PMOokma-Kyi
08/23/2022, 6:51 PMOokma-Kyi
08/23/2022, 6:53 PMOokma-Kyi
08/23/2022, 6:55 PM.save()
ine like so:
var user = getInstance( "User" )
.firstWhere( "email", rc.email )
if( !isNull( user ) ) {
user.setToken( token )
.setExpiration( expiration )
//.save();
}
it doesn't crashbdw429s
08/23/2022, 6:58 PMbdw429s
08/23/2022, 6:58 PMOokma-Kyi
08/23/2022, 6:58 PMbdw429s
08/23/2022, 6:58 PMbdw429s
08/23/2022, 6:59 PMOokma-Kyi
08/23/2022, 6:59 PMbdw429s
08/23/2022, 6:59 PMbdw429s
08/23/2022, 6:59 PMOokma-Kyi
08/23/2022, 6:59 PMbdw429s
08/23/2022, 7:00 PMbdw429s
08/23/2022, 7:00 PMOokma-Kyi
08/23/2022, 7:00 PMbdw429s
08/23/2022, 7:01 PMbdw429s
08/23/2022, 7:01 PMOokma-Kyi
08/23/2022, 7:01 PMbdw429s
08/23/2022, 7:01 PMbdw429s
08/23/2022, 7:01 PMOokma-Kyi
08/23/2022, 7:02 PMOokma-Kyi
08/23/2022, 7:02 PMbdw429s
08/23/2022, 7:02 PMbdw429s
08/23/2022, 7:02 PMOokma-Kyi
08/23/2022, 7:02 PMOokma-Kyi
08/23/2022, 7:03 PMbdw429s
08/23/2022, 7:03 PMbdw429s
08/23/2022, 7:04 PMbdw429s
08/23/2022, 7:04 PMbdw429s
08/23/2022, 7:05 PMOokma-Kyi
08/23/2022, 7:05 PMOokma-Kyi
08/23/2022, 7:05 PMOokma-Kyi
08/23/2022, 7:06 PMAdds a basic where clause to the query and returns the first result.
bdw429s
08/23/2022, 7:09 PMbdw429s
08/23/2022, 7:09 PMbdw429s
08/23/2022, 7:09 PM.first()
method internallybdw429s
08/23/2022, 7:09 PMExecutes the configured query and returns the first entity found. If no entity is found, returns.null
bdw429s
08/23/2022, 7:10 PMnull
bdw429s
08/23/2022, 7:10 PMOokma-Kyi
08/23/2022, 7:11 PMbdw429s
08/23/2022, 7:11 PMbdw429s
08/23/2022, 7:13 PMOokma-Kyi
08/23/2022, 7:14 PMbdw429s
08/23/2022, 7:14 PMOokma-Kyi
08/23/2022, 7:15 PMOokma-Kyi
08/23/2022, 7:15 PMbdw429s
08/23/2022, 7:16 PMbdw429s
08/23/2022, 7:17 PM!isNull( user )
check, right?Ookma-Kyi
08/23/2022, 7:17 PMbdw429s
08/23/2022, 7:17 PMbdw429s
08/23/2022, 7:18 PMbdw429s
08/23/2022, 7:18 PMuser
with no scope, it could be finding another unrelated user object from another scope entirely!bdw429s
08/23/2022, 7:19 PMbdw429s
08/23/2022, 7:19 PM