leancloud_flutter_plugin icon indicating copy to clipboard operation
leancloud_flutter_plugin copied to clipboard

Can I query and update _User in leancloud using the API?

Open zoezhou1999 opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe. Can I query and update _User in leancloud using the API?

Describe the solution you'd like I see I can use the api to login in and sign up but when I want to query the infromation from _User datasets and update some other attributes in it, I cannot use general query code to get them... Thank you for your help!! @LunaGao

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

zoezhou1999 avatar Apr 11 '20 04:04 zoezhou1999

Emmm, I found that login and signup function can be used to query the _User, but I would encounter the error: classname is null 😢

zoezhou1999 avatar Apr 11 '20 08:04 zoezhou1999

AVUser avUser = new AVUser();
  avUser.setUsername(user.userlog.get("username"));
  avUser.setPassword(user.userlog.get("password"));
//  avUser.put("className", "_User");
  try{
//    avUser.find()
    await avUser.login().then((object) {
      avUser = object;
      avUser.put('sex', user.userlog.get('sex'));
      avUser.put('nickname', user.userlog.get('nickname'));
      avUser.save().then((object) {
//        user.userlog.setInt('Id',  object.get("Id"));
        print(object);
        // Updated
      });
    });

  }on Exception catch(e) {
    print('error caught: $e');
  }

Error happens in this code... Strange ENOUGH, because when I update using number attribute it is OK...but failed in String

zoezhou1999 avatar Apr 11 '20 08:04 zoezhou1999