简体   繁体   English

如何使用 next.js 从前端写入我的 lowdb 数据库?

[英]How can I write to my lowdb-Database from the frontend, using next.js?

I am a hobby programmer with some experience in React, primarily using Firebase for my backend.我是一名有一定 React 经验的业余程序员,主要使用 Firebase 作为我的后端。 Recently, I have started using Next.js and am wondering if I can use it as a small JSON-based database for local applications on my Raspberry Pi.最近,我开始使用 Next.js,想知道是否可以将它用作我的 Raspberry Pi 上本地应用程序的基于 JSON 的小型数据库。 I have set up LowDB and can access it from server-side rendered components, but I am unsure of the best way to make them accessible from interactive frontend components, such as allowing user input and saving it to the database.我已经设置了 LowDB 并且可以从服务器端呈现的组件访问它,但我不确定让它们从交互式前端组件访问的最佳方法,例如允许用户输入并将其保存到数据库。 I have considered using Next.js's own API endpoint, but I am unsure if this is the most efficient and desired method.我考虑过使用 Next.js 自己的 API 端点,但我不确定这是否是最有效和最理想的方法。 It feels strange to use a DB query in server-side components but an API for data changes.在服务器端组件中使用 DB 查询感觉很奇怪,但是 API 用于数据更改。

NextJs as great framework derived from React, its more for UI frontend, for interacting with DB normally you would use an NodeJS API framework like NestJs or simply Express with some kickstart templates. NextJs 作为源自 React 的优秀框架,它更多地用于 UI 前端,为了与数据库交互,通常你会使用像 NestJs 这样的 NodeJS API 框架,或者简单地使用一些 kickstart 模板的 Express。 You will not like use SSC since its just not the way/goal it was designed.您不会喜欢使用 SSC,因为它不是设计的方式/目标。 like dentist doctor doing eye check haha就像牙医做眼科检查哈哈

Happy coding!编码愉快!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过 GraphQL 将高级自定义字段从 WordPress 映射到我的 Next.js 前端中的组件,最好的方法是什么? - Mapping Advanced Custom Fields from WordPress to components in my Next.js frontend through GraphQL, best methodology? 如何在 next.js 部署中保留我的 API 机密? - How can I keep my API secret out of my next.js deploy? 如何写入 Next.js 中的 JSON 文件 - How to write to JSON files in Next.js 如何使用 next-connect 删除带有 Next.JS/Mongodb 的文档? - How can I delete a document with Next.JS/Mongodb using next-connect? 如何过滤Next.js中的道具? 无法从 Next.js 中的 componentDidMount 过滤道具中的数据 - How to filter props in Next.js? Can't filter data in props from componentDidMount in Next.js 我想使用 next.js 中的 getInitialProps() 记录我的数据 - I want to log my data using getInitialProps() from next.js 如何使用 next.js 图像并将其附加到背景? - How can I use next.js image and attach it to the background? 在 Next.js getServerSideProps 中,如何从浏览器获取 cookie 以识别用户 - In Next.js getServerSideProps, how can I fetch cookie from browser to identify the user 如何解决 Next.js 中 getServerSideProps 的“序列化”错误 - How can I resolve the error of 'serializing' from getServerSideProps in Next.js 如何在 next.js 中使用动态菜单组件 - How can I use dynamic Menu Component in next.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM