LunaGao / leancloud_flutter_plugin

LeanCloud flutter plugin by Luna Gao
MIT License
33 stars 4 forks source link

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

Open zoezhou1999 opened 4 years ago

zoezhou1999 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago
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