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
[BUG] Mapped type becomes undefined #20
Comments
This is part of design |
That's very sad, since it makes this library unusable for our project, and it was almost fully integrated to it, so we'd probably will need to rewrite all the code again((( Thanks in advance |
Firelord enforces some practices one of it is banning mapped type the biggest concern is, mapped type is very hard to query because you always need to know the value of the key in order to query example data type: type Data= Record<string, number> now imagine you need to query them, how are you going to do it?
well, you need to know both type Data= {a: number}
now imagine somebody created data type like this He need to know 4 information: 3 keys and 1 value before he can even query the data maybe your intention is to reduce the cost, but I believe mapped type is a trap that could cripple your query in the future you might want to convert them into a collection of document instead option is a good idea, I will see what I can do |
I understand why it's banned, but in our case we never use this for any data, that is meant to be queried. The data there is totally dynamic, so we cannot predict. I would even tell you, that we (almost)actually have such mapped object possible in our project as you provided as an example :). In short: type DummyData = {
mapped: Record<string, {
_uid: string;
created_at: Timestamp;
updated_at: Timestamp;
nested: Record<string, {
status: 'active' | 'deleted',
created_at: Timestamp;
updated_at: Timestamp;
}>
}>
} We could use array with objects, but it will be much more inconvenient to get the needed data from the object, because we will need to iterate over all array to search some entry. Updating such data will be also big headache, and I guess it's even not possible to properly check such updates in |
BTW, I would also like to ask a config option, that allows to disable update behavior, that makes every update flat, since we also have some (not nested)objects, that are dynamic at all, what means For example, where there is such object: This feature actually is awesome, but in our case we'd rather turn it off. For now, in our front-end we're just using original firestore's import { writeBatch } from 'firebase/firestore';
import type { WriteBatch } from 'firelordjs';
export const createBatch = () => writeBatch() as WriteBatch; Now I need to make some code for backend - and I'm not sure if I would be able to do such thing there |
I will see what I can do tomorrow |
After some considerations, I allowed I think Firelord should bans what is impossible, not what is possible but could goes wrong, unless it requires minimal efforts from users to make things right Firelord should not interferes too much with how users design their data model Everything you need is available in v2.4.16 |
Great!! Thanks! |
Will you update firelordjs as well? |
I will update it in a day or two, i am a bit busy now
…On Mon, 15 May 2023, 20:19 Arsen Stahanov, ***@***.***> wrote:
Will you update firelordjs as well?
—
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABH4H5K7HQKBKONT7MUR6YDXGINM7ANCNFSM6AAAAAAX7VCUCM>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Hi there, I have some trouble using this library in my project. This was working in
firelordjs@<=2.4
, don't know if it works infirelordjs@>=2.5
, didn't check yet2.4.15
I'm trying to use mapped object in meta type
Mapped type should work as intended
Mapped type becomes undefined in resulted
MetaType['read']
The text was updated successfully, but these errors were encountered: