objectbox / objectbox/objectbox-dart

Direct change of an related object via the main saved obj.

Open
#619 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Dart
Stars
1.2k
Forks
162
Avg merge
15m
Merged PRs (30d)
1

Description

Hello everybody. First of all, this is not a bug, just a question. Why is it not possible to change a value of an related object via the first object that has been saved?

@Entity()
// ignore: camel_case_types
class OB_userdata {
  @Id()
  int id = 0;
  
  List<String> kurse = [];
  String jahrgang = '';
  final secureCredentials = ToOne<SecureCredentials>();
}
@Entity()
class SecureCredentials {
  int id = 0;
  String username = '';
  String password = '';

  void changePassword(String newpassword) {
    this.password = newpassword;
  }

  SecureCredentials({required this.username,required this.password});
} 

Here for example I want to change the username or password which is a related/linked object of the userdata object. But in order to change anything, I have to get the SecureCredentials object as an extra variable, then change the values there and override it in the OB_userdata object (OB_userdata.secureCredentials.target = SecureCredentials(username: 'username', password: 'password');). Thats kind a complecated. In Addition the changePassword Method is also not working.

So my question is, am I blind and didn't see something or is it just the way it is and I have to accept it?

Thanks for any kind of help.
R. Daum

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the OB_userdata.secureCredentials relation and the SecureCredentials.changePassword method shown in the issue. Determine whether changing the related object through the saved object is intended to be supported, and document or define the expected persistence behavior; the issue provides no file or test entry point.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.