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

Add dataType.createWithDocId() method #190

Closed
1 task
Tracked by #189 ...
gmaclennan opened this issue Aug 18, 2023 · 0 comments · Fixed by #192
Closed
1 task
Tracked by #189 ...

Add dataType.createWithDocId() method #190

gmaclennan opened this issue Aug 18, 2023 · 0 comments · Fixed by #192
Assignees

Comments

@gmaclennan
Copy link
Member

gmaclennan commented Aug 18, 2023

Description

The implementation of roles and core ownership and projectInfo / projectSettings requires that docId has a specific value, rather than being random.

We don't want this method to be exposed to any public API (e.g. when we expose datatype instances to the public API), since this should only be used internally.

Implementation

Use a non-shared unique symbol to name the method e.g. const kCreateWithDocId = new Symbol('kCreateWithDocId') and export this locally, but do not include in the public exports of @mapeo/core. Then we can use this by dataType[kCreateWithDocId](docId, value). This is how fastify does it.

Tasks

  • Add method and export symbol
This was referenced Aug 18, 2023
@gmaclennan gmaclennan self-assigned this Aug 18, 2023
gmaclennan added a commit that referenced this issue Aug 18, 2023
Fixes Add `dataType.createWithDocId()` method #190
gmaclennan added a commit that referenced this issue Aug 18, 2023
* feat: Add internal `dataType.createWithDocId()`

Fixes Add `dataType.createWithDocId()` method #190

* Add type def for createWithDocId

* Add tests

* fix typing in unit test
@gmaclennan gmaclennan linked a pull request Aug 18, 2023 that will close this issue
2 tasks
@gmaclennan gmaclennan reopened this Aug 18, 2023
@gmaclennan gmaclennan mentioned this issue Aug 18, 2023
3 tasks
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 a pull request may close this issue.

1 participant