Querying a materialized view: relation does not exist

I define a materialized view as such:
export const usersMv = pgMaterializedView("users_mv").as(
(qb) => {
return qb
.select({
name: users.name,
})
.from(users)
}
)
export const usersMv = pgMaterializedView("users_mv").as(
(qb) => {
return qb
.select({
name: users.name,
})
.from(users)
}
)
Then I query this materialized view:
const results = await db
.select()
.from(usersMv)
const results = await db
.select()
.from(usersMv)
But I get the error:
NeonDbError: relation "users_mv" does not exist
NeonDbError: relation "users_mv" does not exist
I'm using Neon. Does Drizzle know how to create the materialized view for me?
J
joshpachner12d ago
hey @pax , I dont have the answer for ya. but you could create the view normally in your database, and then just add the .existing() at the end of your drizzle view declaration. (thats what i do for my views, and so that i have more control over it in writing the raw sql)