back4app 解析,如何将用户对象 ID 应用到另一个类指针中
Posted
技术标签:
【中文标题】back4app 解析,如何将用户对象 ID 应用到另一个类指针中【英文标题】:back4app parse, how to apply user object Id into another class pointer 【发布时间】:2021-08-07 12:58:35 【问题描述】:这是我的代码
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.. 即使它们是要填写的正确代码。所以任何人都可以帮助解决这个问题吗?请...
【问题讨论】:
【参考方案1】:您需要传递对象(不仅是 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);
【讨论】:
以上是关于back4app 解析,如何将用户对象 ID 应用到另一个类指针中的主要内容,如果未能解决你的问题,请参考以下文章