NextAuth和typeorm-在API端点中检索存储库
我有一个 nextjs app, nextAuth 和 typeorm 。 我正在寻找在API端点中检索特定用户或自定义实体的可能性。 但是,我不知道该如何正确执行此操作。 我不想重新调整每个API上的连接选项以进行TypeOmm,并希望使用适配器设置的连接。 (单身人士的想法)。
有人对如何实现这一目标有任何想法吗?
祝您有美好的一天!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道我是否有您的问题,但我认为最好的方法是创建您的实体,通过typeorm与
同步
Option option> True 连接。它将从定义的模型中创建和更新所有表和列。
然后,您可以创建另一个连接以在API路由中使用。
我认为,如果没有自定义实现服务器实现,Vercel可以通过单个连接部署它。
这个家伙做了一个解决方案,您可以尝试
函数的另一种方法
这是同一 “ rel =“ nofollow noreferrer”> https://github.com/typeorm/typeorm/issues/6241#issuecomment-643690383
I don’t know if I got your question, but I think the best way of doing it is by creating your Entities, connecting via TypeORM with
synchronize
optiontrue
.It will create and update all your tables and columns from your defined model.
Then, you can create another connection to use in your api routes.
I don’t think Vercel can deploy it with a single connection without a custom implementation server implementation.
This guy made a solution that you can try
https://github.com/vercel/next.js/discussions/12254#discussioncomment-19769
This is another approach to the same function
https://github.com/typeorm/typeorm/issues/6241#issuecomment-643690383