back4app 解析,如何将用户对象 ID 应用到另一个 class 指针
back4app parse, how to apply user object Id into another class pointer
这是我的代码
void SignBusiness() async {
ParseUser currentUser = await ParseUser.currentUser() as ParseUser;
var nr = await currentUser.get('objectId');
ParseObject Data = await ParseObject('Business')
..set('NamaBisnis', _nama)
..set('AlamatBisnis', _alamat)
..set('KiloSampah', _kilo)
..set('Pemilik',nr);
await Data.save();
Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);
}
此代码运行良好,这是 运行
的结果
I/flutter (14263): ╭-- Parse Request
I/flutter (14263): curl -X POST -H 'content-type: text/plain; charset=utf-8' -H 'user-agent: Flutter Parse SDK 3.0.0' -H 'X-Parse-Application-Id: nQ1FGO9uklC7f9eMKYDuA16pvAjamCYnbI6xD2Zy' -H 'X-Parse-Session-Token: r:329114ed8d08441517f8a765ea22c902' -H 'X-Parse-Client-Key:
gRsL6bmbByAL3p5CSvjF6nEL1VtHLsqHIVXzm0Or' -d '{"NamaBisnis":"faf","AlamatBisnis":"sss","KiloSampah":12,"Pemilik":"MOpxjAJCl2"}' https://parseapi.back4app.com/classes/Business
I/flutter (14263):
I/flutter (14263): https://parseapi.back4app.com/classes/Business
I/flutter (14263): ╰--
I/flutter (14263): ╭-- Parse Response
I/flutter (14263): Class: Business
I/flutter (14263): Function: ParseApiRQ.create
I/flutter (14263): Status Code: 111
I/flutter (14263): Type: IncorrectType
I/flutter (14263): Error: schema mismatch for Business.Pemilik; expected Pointer<_User> but got String
I/flutter (14263): ╰--
事实证明指针列无法填充用户对象 ID.. 即使它们是填写的正确代码。所以有人可以帮助解决这个问题吗?请..
您需要传递对象(不仅仅是id)。它应该是这样的:
void SignBusiness() async {
ParseUser currentUser = await ParseUser.currentUser() as ParseUser;
ParseObject Data = await ParseObject('Business')
..set('NamaBisnis', _nama)
..set('AlamatBisnis', _alamat)
..set('KiloSampah', _kilo)
..set('Pemilik', currentUser);
await Data.save();
Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);
这是我的代码
void SignBusiness() async {
ParseUser currentUser = await ParseUser.currentUser() as ParseUser;
var nr = await currentUser.get('objectId');
ParseObject Data = await ParseObject('Business')
..set('NamaBisnis', _nama)
..set('AlamatBisnis', _alamat)
..set('KiloSampah', _kilo)
..set('Pemilik',nr);
await Data.save();
Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);
}
此代码运行良好,这是 运行
的结果I/flutter (14263): ╭-- Parse Request
I/flutter (14263): curl -X POST -H 'content-type: text/plain; charset=utf-8' -H 'user-agent: Flutter Parse SDK 3.0.0' -H 'X-Parse-Application-Id: nQ1FGO9uklC7f9eMKYDuA16pvAjamCYnbI6xD2Zy' -H 'X-Parse-Session-Token: r:329114ed8d08441517f8a765ea22c902' -H 'X-Parse-Client-Key:
gRsL6bmbByAL3p5CSvjF6nEL1VtHLsqHIVXzm0Or' -d '{"NamaBisnis":"faf","AlamatBisnis":"sss","KiloSampah":12,"Pemilik":"MOpxjAJCl2"}' https://parseapi.back4app.com/classes/Business
I/flutter (14263):
I/flutter (14263): https://parseapi.back4app.com/classes/Business
I/flutter (14263): ╰--
I/flutter (14263): ╭-- Parse Response
I/flutter (14263): Class: Business
I/flutter (14263): Function: ParseApiRQ.create
I/flutter (14263): Status Code: 111
I/flutter (14263): Type: IncorrectType
I/flutter (14263): Error: schema mismatch for Business.Pemilik; expected Pointer<_User> but got String
I/flutter (14263): ╰--
事实证明指针列无法填充用户对象 ID.. 即使它们是填写的正确代码。所以有人可以帮助解决这个问题吗?请..
您需要传递对象(不仅仅是id)。它应该是这样的:
void SignBusiness() async {
ParseUser currentUser = await ParseUser.currentUser() as ParseUser;
ParseObject Data = await ParseObject('Business')
..set('NamaBisnis', _nama)
..set('AlamatBisnis', _alamat)
..set('KiloSampah', _kilo)
..set('Pemilik', currentUser);
await Data.save();
Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);