Frosty
Frosty
DTDrizzle Team
Created by Frosty on 7/11/2023 in #help
insert with InferModel not working
- inserts won't run or produce errors if you don't include .run() - inserts won't return data if you don't include .all() - inserts won't run if they don't include returning data and you called it with .all() instead of .run()
const newUser = (userData: NewUser) => {
return db.insert(Users).values(userData).returning({id: Users.id}).all()
}

const newTodo = (todoData: NewTodo) => {
return db.insert(Todos).values(todoData).run()
}

const create = async () => {
let result1 = await newUser(<NewUser>{
email: "[email protected]",
password: "12345",
})

// result1 will be [ { id: 1 } ]

await newTodo(<NewTodo>{
owner: result1[0].id,
title: "Test Todo",
notes: "This is a test todo",
completed: false,
})
}
const newUser = (userData: NewUser) => {
return db.insert(Users).values(userData).returning({id: Users.id}).all()
}

const newTodo = (todoData: NewTodo) => {
return db.insert(Todos).values(todoData).run()
}

const create = async () => {
let result1 = await newUser(<NewUser>{
email: "[email protected]",
password: "12345",
})

// result1 will be [ { id: 1 } ]

await newTodo(<NewTodo>{
owner: result1[0].id,
title: "Test Todo",
notes: "This is a test todo",
completed: false,
})
}
7 replies
DTDrizzle Team
Created by Frosty on 7/11/2023 in #help
insert with InferModel not working
had to add .run() to the end of the inserts and it works now https://github.com/drizzle-team/drizzle-orm/issues/815
7 replies
DTDrizzle Team
Created by Frosty on 7/11/2023 in #help
insert with InferModel not working
Think this is a bug in drizzle itself at this point
7 replies
DTDrizzle Team
Created by Frosty on 7/11/2023 in #help
insert with InferModel not working
Its not permissions related, gave everyone/thing permission to read/write
7 replies
DTDrizzle Team
Created by Frosty on 7/11/2023 in #help
insert with InferModel not working
The Studio app can write to the db
7 replies
DTDrizzle Team
Created by Frosty on 7/11/2023 in #help
insert with InferModel not working
Little bit of an update, drizzle won't write to the table at all. It can read it but not write. I removed the timestamp fields it still won't work. The only thing left to try is to remove the autoIncrement attribute
7 replies