#Where's the documentation for table opts like 'label', 'name', 'collection' and 'multiline' for db?

17 messages ยท Page 1 of 1 (latest)

sage bear
#

I've checked table config reference and db columns but I didn't see any section that thoroughly explains the behavior and reason for these options. Some are obvious like label, but others are not, like collection.

  • Does 'multiline' do anything special or does it just have bigger upper limit for characters it can store?
  • How is label and name different?
  • What is collection for?
arctic stirrup
#

Sorry, I don't have all the answers I'm not familiar with the DB integration...

We don't document most of them I think, but we probably should! As you found, your best bet at the moment is "Table configuration reference", and looking in the DB source code...

We have a minimal doc for enum in that section:

A text column can optionally define a list of string literals to serve as an enum for generating types.
....
rank: column.text({ enum: ['user', 'mod', 'admin'] }),
...
(becomes) rank: "user" | "mod" | "admin";

When you use this, Typescript will expect a string matching one of the values in the enum/union.

I think name is used to override the column property. If you have a property authorId, you could override that name with name: "author-id" and then in indexes for example, instead of using authorId you'll need to use author-id. (at least this is what I understand from the docs)

I understand multiline as you can precise that a text column contains line breaks. Now, I don't know if we do anything special with that or if this for you when you sanitize the input or something like that.

I don't know what label and collection are.

@autumn raft since I know you're working a lot on/with DB. If you have time, can you check I'm not talking nonsense here. ๐Ÿ˜„ And maybe you'll have an answer for the other options.
And, do you think this should be in docs? Or is this somewhat related to Drizzle and we should link to their docs?

autumn raft
#

label, name, and collection are auto-generated (collection means table) internal types (name is able to be overridden but really should just rely on the actual table's name and shouldn't be overriden unless you know what your doing.

Everything thing else is as-stated. and should pretty much match between what we have in our docs and the drizzle docs....

arctic stirrup
#

Thanks! So, we might need to add some links to Drizzle... currently we don't mention it at all ๐Ÿ˜… Probably because this is internal, but it could be helpful to avoid duplicating their docs. I'll give a look to see if I can find something useful!

autumn raft
#

I had to read the actual types to be able to fix our DB client the last time they changed things.... no actual helpful info in docs

sage bear
autumn raft
#

collection was supposed to be renamed table

sage bear
autumn raft
#

the bigger issue is that you have a bunch of different column types that have a shared interface, so that the user is not haivng to write out complex chains. but instead a simplified table definition

sage bear
autumn raft
#

Table schema in drizzle:

export const usersTable = sqliteTable("usersTable", {
  id: int().primaryKey({ autoIncrement: true }),
  name: text().notNull(),
  age: int().notNull(),
  email: text().notNull().unique(),
});

table schema in Astro DB

export const usersTable = defineTable({
  columns: {
    id: column.number({ primaryKey: true }),
    name: column.text(),
    age: column.number(),
    email: column.text({ unique: true })
  }
})
#

the bottom example gets converted by AstroDB into the top version

arctic stirrup
# autumn raft I had to read the actual types to be able to fix our DB client the last time the...

Yeah, I can imagine! So, these options, even if they are not useful in most cases, sound like a good candidate to document because they are public and others might have the same kind of questions without taking the time to ask. And, there are probably other things we miss.

I think your experience is valuable as someone building something around Astro DB. So, if there is anything missing or unclear in the docs, we should improve that! We can't document everything, especially when this is built upon another tool, but at least we should tell people where they can get more info!

So, I know you don't necessarily have time to write the docs, but if you're able to tell me what I should be looking for (ie. what is missing/wrong, anything really! I can then sort through what needs to be documented and what may not be for Astro Docs), I can try to write an update for that page and... well, a review from you would be of course helpful to be sure I'm not writing nonsense. ๐Ÿ˜„ But at least, you don't have to do the search/writing. Not necessarily now of course, no rush! A discussion in docs or a thread somewhere when you have time will work!
I can also try to check what's missing myself and submit this list to you so you can complete it, if that suits you better!

EDIT: oh now I reread your answer, I wonder if you mean in Drizzle Docs or Astro Docs... well if this is in Astro Docs, we can fix that!

arctic stirrup