JP
JP
SSolidJS
Created by Eve on 10/15/2024 in #support
unwrap doesn't seem to do anything
const ppl = unwrap(people);
setPeople([10])
console.log('store: ', people)
console.log('unwrap: ',ppl)
const ppl = unwrap(people);
setPeople([10])
console.log('store: ', people)
console.log('unwrap: ',ppl)
I expected ppl to be [], but in the console it shows as [10] I'm totally new to solid BTW. After reading the unwrap documentation, I realized I need to understand Solid concepts much more thoroughly. If someone here could provide guidance on materials I can read to gain a better understanding, it would be greatly appreciated. I've already read the documentation and watched all of Ryan's videos and articles that I could find.
6 replies
DTDrizzle Team
Created by JP on 5/15/2024 in #help
This query is to much for me :)
2 replies
DTDrizzle Team
Created by JP on 5/14/2024 in #help
one-to-many self reference
Thank you @⚡Z.E.U.S⚡! it's working. I've been struggling with this for hours!
8 replies
DTDrizzle Team
Created by JP on 5/14/2024 in #help
one-to-many self reference
I'll try that right now!
8 replies
DTDrizzle Team
Created by JP on 5/14/2024 in #help
one-to-many self reference
but I don't know in this case which is the 'other side' of the relationship 🙂
8 replies
DTDrizzle Team
Created by JP on 5/14/2024 in #help
one-to-many self reference
Angelelz

166d ago
I think your problem is that you have a relationName defined only on one side.
You have to either delete it or add it on both sides
Angelelz

166d ago
I think your problem is that you have a relationName defined only on one side.
You have to either delete it or add it on both sides
I saw this, I'll try to fix it
8 replies
DTDrizzle Team
Created by JP on 5/14/2024 in #help
one-to-many self reference
Thank you @⚡Z.E.U.S⚡! this worked:
export const contacts = mysqlTable("contacts", {
id: int("id").primaryKey(),
parentId: int("parent_id").references((): AnyMySqlColumn => contacts.parentId),
...
}, (table) => {
return {
parentReference: foreignKey({
columns: [table.parentId],
foreignColumns: [table.id],
name: "fk_contacts_parent_id"
}),
}
})
export const contacts = mysqlTable("contacts", {
id: int("id").primaryKey(),
parentId: int("parent_id").references((): AnyMySqlColumn => contacts.parentId),
...
}, (table) => {
return {
parentReference: foreignKey({
columns: [table.parentId],
foreignColumns: [table.id],
name: "fk_contacts_parent_id"
}),
}
})
I'm not sure if it's right, but it doesn't show errors, so, nice!! Also this code does not show any error:
export const contactsRelations = relations(contacts, ({ many, one }) => ({
contactCustomFields: many(contactCustomFields, { relationName: 'contactCustomFields' }),
familyMembers: many(contacts, { relationName: 'familyMembers' }),
}))
export const contactsRelations = relations(contacts, ({ many, one }) => ({
contactCustomFields: many(contactCustomFields, { relationName: 'contactCustomFields' }),
familyMembers: many(contacts, { relationName: 'familyMembers' }),
}))
but this code below fails with There is not enough information to infer relation "contacts.familyMembers
const result = await db.query.contacts.findMany({
with: {
familyMembers: true,
},
limit: 1
})
const result = await db.query.contacts.findMany({
with: {
familyMembers: true,
},
limit: 1
})
8 replies