How to insert into a table without providing values

I've got the following schema for users in sqlite, it only contains an id, which is an auto incrementing primary key.
export const users = sqliteTable("users", {
id: integer("id").primaryKey({ autoIncrement: true })
});
export const users = sqliteTable("users", {
id: integer("id").primaryKey({ autoIncrement: true })
});
I am trying to create a new record, that will auto generate the new id for me and return it.
async () => {
return await db.insert(users).values({}).returning().get();
}
async () => {
return await db.insert(users).values({}).returning().get();
}
This results in the following error:
SqliteError: near ")": syntax error ...
}
SqliteError: near ")": syntax error ...
}
I can pass in an ID to the value object and it will run and create a new record without error but that means I am generating the IDs, rather than the database and I'd like to avoid that. Thanks
1 Reply
mr_pablo
mr_pablo2y ago
Try removing the empty object inside values() ? or try removing values() altogether?
Want results from more Discord servers?
Add your server