Skip to content

(DOCSP-26981): @realm/reactify - Change an Object Model - React Native #2399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

mohammadhunan-dev
Copy link
Contributor

@mohammadhunan-dev mohammadhunan-dev commented Dec 13, 2022

Pull Request Info

Jira

Staged Changes

Reminder Checklist

If your PR modifies the docs, you might need to also update some corresponding
pages. Check if completed or N/A.

  • [N/A] Create Jira ticket for corresponding docs-app-services update(s), if any
  • [N/A] Checked/updated Admin API
  • [N/A] Checked/updated CLI reference

Review Guidelines

REVIEWING.md

@github-actions
Copy link

github-actions bot commented Dec 13, 2022

Readability for Commit Hash: 019253c

You can see any previous Readability scores (if they exist) by looking
at the comment's history.

Flesch Reading Ease scores for changed documents:

  • source/sdk/react-native/realm-database/change-an-object-model: 55.64

The following table can be helpful in assessing the readability score of a document.

Score Difficulty
90-100 Very Easy
80-89 Easy
70-79 Fairly Easy
60-69 Medium
50-59 Fairly Hard
30-49 Hard
0-29 Very Hard

@mohammadhunan-dev mohammadhunan-dev changed the title (DOCSP-26981): Change an Object Model - React Native (DOCSP-26981): @realm/reactify - Change an Object Model - React Native Dec 13, 2022
// :snippet-start: add-a-property-to-schema
// :replace-start: {
// "terms": {
// "MyPerson": "Person"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] Why is this replace needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already a Person schema with different properties used elsewhere in the unit test suite.

Comment on lines 100 to 107
<react-native-schema-version>` ``1`` has a ``Person`` object type with a
``firstName``, and ``lastName`` property. The developer decides to add an
``age`` property to the ``Person`` class.

To migrate the realm to conform to the updated ``Person`` schema, the
developer sets the realm's :ref:`schema version <react-native-schema-version>` to
``2``.
developer sets the realm's schema version in the ``RealmConfiguration`` to ``2``.
Finally, the developer passes the configuration object to the
``createRealmContext()`` method.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to refer to user as 'the developer' here reads weird to me, and goes against the mongoDB style guide, which advocates 2nd person and imperative mood - https://www.mongodb.com/docs/meta/style-guide/writing/write-to-the-user/

could you refactor these sentences with this in mind?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're very inconsistent with using "developer" vs "user" throughout our docs, here are just a few examples of where we use developer (Update a Realm Object Schema - Flutter SDK, Change an Object Model - Swift SDK, Modify an Object Schema - Node.js SDK).

It's an easy enough change for me to make "developer" -> "user" if you feel particularly strongly about it, but I do think we might prefer to use "developer" for the following reasons:

  • Main reason: "User" is ambiguous. Does this refer to the user using the application, or the user of realm (i.e the application developer), or the reader of this docs page (who may be one of many personas) ?
  • Supplementary reason: To highlight that this is a specific example of how change the schema. Using the word "developer" indicates that someone else is doing this, not that this is the only way to do it. The

Also, it seems like the mongoDB style guide is specifically advocating not to use the phrase "the user".

Screen Shot 2023-01-03 at 11 53 45 AM

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but i was commenting that it should be changed to 2nd person ('you') or imperative, not 'user', so i think the initial comment still stands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, altered to 'you' instead now.

Copy link
Collaborator

@mongodben mongodben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work! just couple of small things.

``2`` and defines a migration function to convert the ``Object ID`` type to a
``string`` type.
To migrate the realm to conform to the updated ``Task`` schema, the developer
creates a :js-sdk:`Configuration <Realm.html#~Configuration>` object and
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@mongodben mongodben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking better, just a few things remaining

Comment on lines 105 to 106
To migrate the realm to conform to the updated ``Person`` schema, the
developer sets the realm's :ref:`schema version <react-native-schema-version>` to
``2``.
developer sets the realm's schema version in the ``Configuration`` to ``2``.
Copy link
Collaborator

@mongodben mongodben Jan 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to imperative/2nd person

developer sets the realm's :ref:`schema version <react-native-schema-version>` to
``2``.
developer sets the realm's schema version in the ``Configuration`` to ``2``.
Finally, you pass the configuration object to the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Finally, you pass the configuration object to the
Finally, pass the configuration object to the

Comment on lines 142 to 143
To migrate the realm to conform to the updated ``Person`` schema, the
developer sets the realm's schema version to 2 in the ``Configuration``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To migrate the realm to conform to the updated ``Person`` schema, the
developer sets the realm's schema version to 2 in the ``Configuration``
To migrate the realm to conform to the updated ``Person`` schema,
set the realm's schema version to 2 in the ``Configuration``


To migrate the realm to conform to the updated ``Person`` schema, the
developer sets the realm's schema version to 2 in the ``Configuration``
object. Finally, you pass the configuration object to the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
object. Finally, you pass the configuration object to the
object. Finally, pass the configuration object to the

developer sets the realm's :ref:`schema version <react-native-schema-version>` to
``2`` and defines a migration function to set the value of ``fullName`` based
on the existing ``firstName`` and ``lastName`` properties.
To migrate the realm to conform to the updated ``Person`` schema, you create a :js-sdk:`Configuration <Realm.html#~Configuration>` object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To migrate the realm to conform to the updated ``Person`` schema, you create a :js-sdk:`Configuration <Realm.html#~Configuration>` object
To migrate the realm to conform to the updated ``Person`` schema, create a :js-sdk:`Configuration <Realm.html#~Configuration>` object

To migrate the realm to conform to the updated ``Person`` schema, you create a :js-sdk:`Configuration <Realm.html#~Configuration>` object
and set the realm's schema version to ``2``, and define a migration function that
sets the value of ``fullName`` based on the existing ``firstName`` and ``lastName``
properties. Finally, you pass the configuration object to the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
properties. Finally, you pass the configuration object to the
properties. Finally, pass the configuration object to the

developer sets the realm's :ref:`schema version <react-native-schema-version>` to
``2`` and defines a migration function to convert the ``Object ID`` type to a
``string`` type.
To migrate the realm to conform to the updated ``Task`` schema, you create a
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To migrate the realm to conform to the updated ``Task`` schema, you create a
To migrate the realm to conform to the updated ``Task`` schema, create a

To migrate the realm to conform to the updated ``Task`` schema, you create a
``Configuration`` object and set the realm's schema version to ``2``, and
define a migration function to convert the integer type to an ``Object ID``
type. Finally, you pass the configuration object to the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type. Finally, you pass the configuration object to the
type. Finally, pass the configuration object to the

Copy link
Collaborator

@mongodben mongodben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. some small suggestions about the 2nd person/imperative throughout

@mohammadhunan-dev mohammadhunan-dev merged commit e86e607 into mongodb:realm-react-guidance Jan 4, 2023
mongodben added a commit that referenced this pull request Feb 10, 2023
#2399)

## Pull Request Info

### Jira

- https://jira.mongodb.org/browse/DOCSP-26981

### Staged Changes

- [Change an Object Model - React
Native](https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/DOCSP-26981-Change-A-ROM/sdk/react-native/realm-database/change-an-object-model/)

### Reminder Checklist

If your PR modifies the docs, you might need to also update some
corresponding
pages. Check if completed or N/A.

- [N/A] Create Jira ticket for corresponding docs-app-services
update(s), if any
- [N/A] Checked/updated Admin API
- [N/A] Checked/updated CLI reference

### Review Guidelines


[REVIEWING.md](https://github.com/mongodb/docs-realm/blob/master/REVIEWING.md)

Co-authored-by: Mohammad Hunan Chughtai <[email protected]>
Co-authored-by: Ben Perlmutter <[email protected]>
mongodben added a commit that referenced this pull request Mar 21, 2023
#2399)

## Pull Request Info

### Jira

- https://jira.mongodb.org/browse/DOCSP-26981

### Staged Changes

- [Change an Object Model - React
Native](https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/DOCSP-26981-Change-A-ROM/sdk/react-native/realm-database/change-an-object-model/)

### Reminder Checklist

If your PR modifies the docs, you might need to also update some
corresponding
pages. Check if completed or N/A.

- [N/A] Create Jira ticket for corresponding docs-app-services
update(s), if any
- [N/A] Checked/updated Admin API
- [N/A] Checked/updated CLI reference

### Review Guidelines


[REVIEWING.md](https://github.com/mongodb/docs-realm/blob/master/REVIEWING.md)

Co-authored-by: Mohammad Hunan Chughtai <[email protected]>
Co-authored-by: Ben Perlmutter <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants