Skip to content
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

RJS-1413: Add support for a logical counter as a presentation data type #6694

Merged
merged 65 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e4f9dee
Group schema normalization tests into suites.
elle-j May 25, 2024
a29ad5e
Allow 'counter' in schema parser.
elle-j May 25, 2024
c823376
Test schema parser with 'counter'.
elle-j May 25, 2024
c4dabd4
Add Counter class.
elle-j May 25, 2024
1c6d13c
Implement creating a counter on Realm object.
elle-j May 25, 2024
5067095
Add implementation to Counter.
elle-j May 27, 2024
98c1222
Expose Core's 'add_int()'.
elle-j May 27, 2024
5038b84
Add object property getter.
elle-j May 27, 2024
feb3e5f
Export types.
elle-j May 27, 2024
1c6b5b7
Test create and access via 'realm.create()' (input: nums and Counter).
elle-j May 27, 2024
6ceec82
Test create and access via 'realm.create()' (input: collections).
elle-j May 27, 2024
1f67652
Test create and access via collection accessors.
elle-j May 27, 2024
b26fbf0
Test updating the counter value.
elle-j May 27, 2024
f345f19
Test updating the Realm object counter property.
elle-j May 27, 2024
0a1717b
Move common logic to shared functions.
elle-j May 28, 2024
1542b1e
Test updating the Realm object collection property.
elle-j May 28, 2024
12e8bfd
Test returning different reference for each access.
elle-j May 28, 2024
9e2c996
Test throwing when updating by non-integer.
elle-j May 28, 2024
46a836e
Change how a counter should be defined in the schema.
elle-j May 28, 2024
b48806a
Rename test property.
elle-j May 28, 2024
5489259
Add 'skips' to tests that await implementation.
elle-j May 28, 2024
e4d7917
Add 'presentations' to the stored sdk-specifc schema info.
elle-j May 28, 2024
be5f1e9
Add 'isCreating' argument to object property setters to disallow cert…
elle-j May 29, 2024
0a8b888
Test throwing when resetting via property setter.
elle-j May 29, 2024
a58a28e
Test throwing outside transaction.
elle-j May 29, 2024
b0f8521
Test throwing if setting regular int to counter.
elle-j May 29, 2024
4495dd4
Test throwing if invalidated object.
elle-j May 29, 2024
9763284
Extend 'Unmanaged' with Counter and allowing number.
elle-j May 29, 2024
afa7ad4
Throw custom message if getting value on invalid object.
elle-j May 29, 2024
59ec5dc
Implement 'Counter.set()'.
elle-j May 29, 2024
81723b1
Disallow counter as mixed.
elle-j May 30, 2024
f3614f1
Test throwing if used as mixed.
elle-j May 30, 2024
2c9541b
Test filtering.
elle-j May 30, 2024
1b351c9
Fixing returning null if counter is null.
elle-j May 30, 2024
b975c56
Remove support for collections of counters.
elle-j May 30, 2024
2ef6ef2
Test updating Realm object counter prop via UpdateMode.
elle-j May 30, 2024
1b54593
Fix Unmanaged type for Counter.
elle-j May 31, 2024
3cd97d6
Add Unmanaged RealmSet.
elle-j May 31, 2024
700535e
Update API docs.
elle-j May 31, 2024
db7e822
Remove implicit coercion to number due to TS not supporting it.
elle-j May 31, 2024
6807967
Test 'Realm.schema'.
elle-j May 31, 2024
ca45cc4
Replace 'Object.defineProperty' with Symbols.
elle-j May 31, 2024
61b42cc
Add CHANGELOG entry.
elle-j May 31, 2024
7d2cc76
Change default value in test to non-zero.
elle-j May 31, 2024
baffff7
Test throwing when setting 'Counter.value' directly.
elle-j May 31, 2024
d8e8442
Make 'describe' test names lowercase.
elle-j May 31, 2024
92a5803
List what is not supported onto the 'Counter' API docs.
elle-j May 31, 2024
5e0836b
Move 'expectCounter' to common file.
elle-j May 31, 2024
4abc2ae
Remove link to API ref docs in CHANGELOG if doing RC release.
elle-j May 31, 2024
d67b258
Refactor a test to use `map` instead of for-loop
elle-j May 31, 2024
f9e1b99
Update error message from 'floating point' to 'decimal'.
elle-j May 31, 2024
abe6298
[12.10.0-rc.0] Bump version (#6696)
fealebenpae May 31, 2024
1ffb0d8
Prepare for vNext (#6697)
github-actions[bot] May 31, 2024
4d23e4a
Update formatting.
elle-j Jun 10, 2024
f4bd3fe
Update test variable name.
elle-j Jun 10, 2024
5042775
Add links in CHANGELOG.
elle-j Jun 10, 2024
8ceec4b
Update API docs formatting.
elle-j Jun 10, 2024
87496a5
Update initial value in test from 0 to 10.
elle-j Jun 11, 2024
5e6ffff
Refactor similar tests into for-loop.
elle-j Jun 11, 2024
21a32bb
Point to Core v14.10.0.
elle-j Jun 11, 2024
dc34a1b
Update Counter API docs.
elle-j Jun 12, 2024
fca50ae
Remove redundant comment.
elle-j Jun 12, 2024
d4c2f3d
Refactor logic allowing/disallowing setting a counter.
elle-j Jun 12, 2024
d111a7f
Update type name w/o abbreviation
elle-j Jun 12, 2024
d936655
Fix CHANGELOG after merge.
elle-j Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
* Reduce the size of the local transaction log produced by creating objects, improving the performance of insertion-heavy transactions. ([realm/realm-core#7734](https://github.com/realm/realm-core/pull/7734))

### Fixed
* A non-streaming progress notifier would not immediately call its callback after registration. Instead you would have to wait for a download message to be received to get your first update - if you were already caught up when you registered the notifier you could end up waiting a long time for the server to deliver a download that would call/expire your notifier. ([#7627](https://github.com/realm/realm-core/issues/7627), since v12.8.0)
* After compacting, a file upgrade would be triggered. This could cause loss of data for synced Realms. ([realm/realm-core#7747](https://github.com/realm/realm-core/issues/7747), since 12.7.0-rc.0)
* The function `immediatelyRunFileActions` was not added to the bindgen's opt-list. This could lead to the error `TypeError: app.internal.immediatelyRunFileActions is not a function`. ([#6708](https://github.com/realm/realm-js/issues/6708), since v12.8.0)
* Encrypted files on Windows had a maximum size of 2 GB even on x64 due to internal usage of `off_t`, which is a 32-bit type on 64-bit Windows. ([realm/realm-core#7698](https://github.com/realm/realm-core/pull/7698), since the introduction of encryption support on Windows - likely in v1.11.0)
* Tokenizing strings for full-text search could lead to undefined behavior. ([realm/realm-core#7698](https://github.com/realm/realm-core/pull/7698), since v11.3.0-rc.0)


### Compatibility
* React Native >= v0.71.4
* Realm Studio v15.0.0.
Expand All @@ -23,6 +21,48 @@
### Internal
* Upgraded Realm Core from v14.7.0 to v14.10.0. ([#6701](https://github.com/realm/realm-js/issues/6701))

## 12.10.0-rc.0 (2024-05-31)

### Enhancements
* A `counter` presentation data type has been introduced. The `int` data type can now be used as a logical counter for performing numeric updates that need to be synchronized as sequentially consistent events rather than individual reassignments of the number. ([#6694](https://github.com/realm/realm-js/pull/6694))
elle-j marked this conversation as resolved.
Show resolved Hide resolved
* See the [API docs](https://www.mongodb.com/docs/realm-sdks/js/latest/classes/Realm.Types.Counter.html) for more information about the usage, or get a high-level introduction about counters in the [documentation](https://www.mongodb.com/docs/atlas/app-services/sync/details/conflict-resolution/#counters).
```typescript
class MyObject extends Realm.Object {
_id!: BSON.ObjectId;
counter!: Realm.Types.Counter;

static schema: ObjectSchema = {
name: "MyObject",
primaryKey: "_id",
properties: {
_id: { type: "objectId", default: () => new BSON.ObjectId() },
counter: "counter",
// or: counter: { type: "int", presentation: "counter" },
},
};
}

const realm = await Realm.open({ schema: [MyObject] });
const object = realm.write(() => {
return realm.create(MyObject, { counter: 0 });
});

realm.write(() => {
object.counter.increment();
object.counter.value; // 1
object.counter.decrement(2);
object.counter.value; // -1
});
```

### Fixed
* A non-streaming progress notifier would not immediately call its callback after registration. Instead you would have to wait for a download message to be received to get your first update - if you were already caught up when you registered the notifier you could end up waiting a long time for the server to deliver a download that would call/expire your notifier. ([#7627](https://github.com/realm/realm-core/issues/7627), since v12.8.0)

### Compatibility
* React Native >= v0.71.4
* Realm Studio v15.0.0.
* File format: generates Realms with format v24 (reads and upgrades file format v10).

## 12.9.0 (2024-05-23)

### Enhancements
Expand Down
1 change: 1 addition & 0 deletions integration-tests/tests/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import "./tests/alias";
import "./tests/array-buffer";
import "./tests/bson";
import "./tests/class-models";
import "./tests/counter";
import "./tests/dictionary";
import "./tests/dynamic-schema-updates";
import "./tests/enums";
Expand Down
Loading
Loading