Closed MRDGH2821 closed 7 months ago
Hey! First of all, which version are you using? Please make sure you use the latest RC (10). It's ready for launch. I'm just waiting for the blog post announcement to be published.
The docs are here: https://next.typesaurus.com/get-started/
So it would be nice to see a comparative study & conversion of Cloud Firestore's DB layout into Typesaurus schema.
That would be nice indeed! I'll keep it in mind and probably write a doc about that in the future.
Regarding your JSON, sorry, I'm a bit confused. Is it a single document, or do you describe collections like that?
I assume that it's a document as webhooks
can't be a document (unless I missed something fundamental), so here's the example:
import { schema } from "typesaurus";
const db = schema(($) => ({
docs: $.collection<Doc>(),
}));
interface Doc {
servers: Servers;
webhooks: Webhooks;
user_preferences: UserPreferences;
}
type Servers = Record<number, Server>;
interface Server {
name: string;
id: number;
date: Date;
}
type Webhooks = Record<number, string>;
type UserPreferences = Record<number, UserPreference>;
interface UserPreference {
user_id: number;
settings: Settings;
}
type Settings = Record<string, string>;
Of course, it's a very simplified example, but if you could please tell me more, I'll try to help. That would be great. I would also appreciate it if you can read the "Designing schema" section in the docs and see if it answers your questions: https://next.typesaurus.com/design/best-practices/
Actually the webhooks part was a mistake from my side π
So what I mean by live example is this:
There are 3 collections: servers
, users
& express-sessions
. Focusing on servers
& users
for now.
So, inside the collection, I have server id as the "document" name & it has document of 3 properties a.k.a "fields".
Then there's users
collection:
This one has an firestore autogenerated ID (by mistake) which I do not want (I was looking around & checking out stuff)
And the other document has user id as the "document" name with 2 "fields".
What I need is a direct/live comparision/examples to convert existing firestore layout into typesaurus schema. Suppose this is the schema I give you, how would you translate it into typesaurus schema?
@MRDGH2821 do you mind if I write a doc using your example and link to this issue? I think your schema is very straightforward but has some nuances, like express-sessions
having a dash in it, so it will be a good quickstart example.
@MRDGH2821 do you mind if I write a doc using your example and link to this issue? I think your schema is very straightforward but has some nuances, like
express-sessions
having a dash in it, so it will be a good quickstart example.
I have no problems, as long as those ID values are not in the example.
(Maybe I should have properly censored it from my sideπ¬π )
Can I see how my existing firestore db console screenshot translates to Typesaurus schema?π€
I may have missed the doc update, so is there any link/reference?π€
Hey, thank you for waiting! Here's the doc I promised: https://next.typesaurus.com/design/adopting. Please let me know if you have more questions or any feedback on this and other schema design docs on the website.
Hereβs an example of a simple real-life database. The top-level properties are the collections, {fooId} are the dynamic ids.
In the guide, I'm confused about dynamic ids
, are these IDs autogenerated by firebase when a new entry is added?
If yes, then how can I enter a custom ID?π€ My firebase DB screenshot has custom IDs
If no, then I feel I haven't understood the schema definition (i.e. how to enter custom ID) in the docs. Maybe I need to experiment a little after which I will come to understand π€
I will check this out this evening π«‘
I didn't understand how to create a schema when I already have some data in Cloud Firestore. I mean to say, I did not understand how to translate the layout I see in Firebase console to the schema in typesaurus.
So it would be nice to see a comparative study & conversion of Cloud Firestore's DB layout into Typesaurus schema.
I use Cloud firestore in discord bots, so here is the layout I see in Firestore console (given in json format):
The value inside
<
&>
indicate document ID with respect to Firestore. And with respect to the discord bot, it refers to specific values (not the autogenerated values).