[GH-ISSUE #57] Exported data is not type-safe by default #39

Closed
opened 2026-05-23 08:27:41 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @appy-one on GitHub (Dec 31, 2021).
Original GitHub issue: https://github.com/appy-one/acebase/issues/57

Originally assigned to: @appy-one on GitHub.

Data that has no JSON notation such as dates, binary data and path references are not exported with the type_safe flag set to true by default; the flags itself is not documented and the TS method definition does not allow it to be set. The flag should be set to true by default and allowed to be changed.

Example:

const ref = db.ref('typesafety');
await ref.set({ 
   text: 'Checking typesafety',
   date: new Date(),
   binary: new TextEncoder().encode('binary data'),
   reference: new PathReference('some/other/data')
});
let json = '';
await ref.export({ write: str => json += str });

Value of json: {"text":"Checking typesafety","date":"2021-12-31T11:55:14.380Z","binary":"<~@VK^gEd8d<@<>o~>","reference":"some/other/data"}

Expected (typesafe) value: {"text":"Checking typesafety","date":{".type":"Date",".val":"2021-12-31T11:55:14.380Z"},"binary":{".type":"Buffer",".val":"<~@VK^gEd8d<@<>o~>"},"reference":{".type":"PathReference",".val":"some/other/data"}}

Originally created by @appy-one on GitHub (Dec 31, 2021). Original GitHub issue: https://github.com/appy-one/acebase/issues/57 Originally assigned to: @appy-one on GitHub. Data that has no JSON notation such as dates, binary data and path references are not exported with the `type_safe` flag set to `true` by default; the flags itself is not documented and the TS method definition does not allow it to be set. The flag should be set to `true` by default and allowed to be changed. Example: ```js const ref = db.ref('typesafety'); await ref.set({ text: 'Checking typesafety', date: new Date(), binary: new TextEncoder().encode('binary data'), reference: new PathReference('some/other/data') }); let json = ''; await ref.export({ write: str => json += str }); ``` Value of `json`: `{"text":"Checking typesafety","date":"2021-12-31T11:55:14.380Z","binary":"<~@VK^gEd8d<@<>o~>","reference":"some/other/data"}` Expected (typesafe) value: `{"text":"Checking typesafety","date":{".type":"Date",".val":"2021-12-31T11:55:14.380Z"},"binary":{".type":"Buffer",".val":"<~@VK^gEd8d<@<>o~>"},"reference":{".type":"PathReference",".val":"some/other/data"}}`
gitea-mirror 2026-05-23 08:27:41 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@appy-one commented on GitHub (Dec 31, 2021):

Fix published in acebase v1.13.0

<!-- gh-comment-id:1003379922 --> @appy-one commented on GitHub (Dec 31, 2021): Fix published in acebase v1.13.0
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase#39
No description provided.