I build a rust database with diesel just like the docs and it worked fine in the terminal commands
fn main() {
use database::schema::posts::dsl::*;
let connection = establish_connection();
let results = posts.filter(published.eq(true))
.limit(5)
.load::<Post>(&connection)
.expect("Error loading posts");
println!("Displaying {} posts", results.len());
for post in results {
println!("{}", post.title);
println!("----------\n");
println!("{}", post.body);
}
}
but later when I used the following function inside yew I got the error
pub fn get_posts() -> Vec<Post> {
let connection = establish_connection();
use schema::posts::dsl::*;
let results = posts.load::<Post>(&connection).expect("Error loading posts");
results
}
Uncaught TypeError: Failed to resolve module specifier "env". Relative references must start with either "/", "./", or "../".
- I am using postgres app on mac
- i am using
DATABASE_URL=postgres://apple:password@localhost/postgres
for postgresql connect