#How to use MongoDB / Mongoose with SolidStart?

29 messages · Page 1 of 1 (latest)

smoky wigeon
#

I'm new to SolidStart and I'm trying to learn by building a simple wishlist website. I find the documentation a bit confusing – the project template seems to autogenerate a server, but I'm not sure where to edit it / how to use it. Say that I want to do something really simple, like save to and query from a MongoDB database, how would I do that in SolidStart (bare template, JavaScript)?

Is it even necessary to use a MongoDB database? If not, are there any data persistence examples using the functions defined in this page?
https://start.solidjs.com/core-concepts/data-loading

fiery walrus
#

you might be better off trying to start with create-jd-app which spins you up with prisma as an ORM and a local sql-lite database

#

@arctic warren runs that project

arctic warren
#

Yep just run

pnpm create jd-app@latest

Choose prisma and you will have a fully functioning app with prisma configured and solidstart

smoky wigeon
#

Wow! Thank you guys so much

fiery walrus
#

👍

smoky wigeon
#

I'm going to try deploying the web app once I finish. We'll see how that goes...

fiery walrus
#

gl

smoky wigeon
# fiery walrus solidstart does not come with a database. Mongo is one you could use, it might n...

Can you give me a brief overview of what I need to do in order to use MongoDB / mongoose? I see that you have API routing as well as directories for backend and models. I'm confused about the basics – where to put different files, what to put in the files, and why. What functions should the actual page call? etc.
Also, any SolidStart & MongoDB guides you referred to while building this would be helpful. I've only managed to find two or three simple demos in typescript, and the API routing outlined in those guides did not work...
As mentioned before, I only just want to accomplish adding to / querying from the database, through forms and simple displays.
Thank you so much!!!

fiery walrus
obsidian marlin
smoky wigeon
#

I tried to follow that guide already but ran into some api routing problems. Trying to figure that out this week.

arctic warren
#

Tho it looks like this guide is a bit outdated, like you don’t need to install dotenv by yourself months already

smoky wigeon
#

I'm not really sure what this means...

arctic warren
#

console.log(poems())

Also make sure to wrap this page with suspense, because reading routeData (a resource) triggers suspense so that might cause a blank screen when the page has a lack of suspense boundaries

smoky wigeon
#

Line 15 is console.log(poems());
Console.log(typeof poems) gives undefined

arctic warren
#

Where is useRouteData coming from

#

And will it work if you change the extension to .tsx

#

Instead of.jsx

smoky wigeon
#

And changing it to tsx doesn't work either

arctic warren
#

routeData should be exported

#

so it should be declared outside of this component declaration