我如何使用nestjs创建influxdb?

发布于 2025-01-14 09:51:45 字数 94 浏览 2 评论 0原文

我是一名新软件开发人员。我没有太多的软件背景,但我正在尽力学习。有人用nestjs做过influxdb操作吗?如果有的话,可以分享一下之前的经历吗? 预先感谢您的阅读和回复。

i am a new software developer. I don't have much software background, but I'm trying to learn as much as I can. Is there anyone who has done influxdb operation with nestjs before? If yes, can you share your previous experiences?
Thank you in advance for reading and replying.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

憧憬巴黎街头的黎明 2025-01-21 09:51:45

如果你考虑使用nestjs,你将面临很多困难......也许我错了,你低估了自己,但如果你问是否可以将数据库连接到你的后端,那么nest肯定会非常复杂 - >能够弄清楚事情......并不是说你不能,而是你可能想

首先考虑 Express 只是为了了解后端是如何工作的 ->无需规划所有 dtos 的控制器服务 yatta yatta yatta .. 您可以使用express 完成所有相同的事情,事实上开发人员使用express 来制作下一个->然后添加了很多不符合 Express 标准的企业级内容。

另外,如果您是编码新手,那么打字稿可能有点多。非常抱歉,如果这不是您想要的,我并不是想引导您走向任何特定的方向。但我有时会花12小时 - 36小时试图弄清楚我之前已经工作过的事情...注射和nest附带的所有东西都很好,但如果你不知道为什么需要它,那么它会非常糟糕很难真正学习这些概念。

教别人口渴时如何喝水要容易得多。

否则你会花很多时间去学习 Nest

强大的 es6 / ts 的先决条件是必须的

es6 部分在我看来更重要,因为例如处理所有异步的事情以及一切的方式如果没有深入了解幕后发生的事情,其格式非常混乱。

---我确信你会想通过艰难的方式找到答案->如果你能度过难关,我不会责怪你,你会成为一个更坚强的人 =) 但在这里试试这个尺码。

https://www.npmjs.com/package/nest-influxdb

import { Module } from "@nestjs/common";
import { InfluxDbModule, InfluxModuleOptions } from "nest-influxdb";
import { UtilsModule } from "./utils/utils.module";
import { ConfigService } from "./utils/config/config.service";
 
@Module({
    imports: [
        InfluxDbModule.forRootAsync({
            imports: [UtilsModule],
            inject: [ConfigService],
            useFactory: async (
                config_servie: ConfigService
            ): Promise<InfluxModuleOptions> => {
                return {
                    host: config_servie.get("INFLUX_HOST")
                };
            }
        }),
        BlogModule
    ],
    controllers: [AppController],
    providers: [AppService]
})
export class AppModule {}

这会去在你的根级模块文件中 ->然后您将使用 for feature 方法来处理根数据库中的特定内容,

检查 Nest 文档以了解它如何与其他数据库配合使用,然后尝试将这些点与上面的包连接起来

Your going to face many hardships if you consider using nestjs... Maybe im wrong and your underselling yourself, but if you are asking if its possible to connect a database to your backend then nest is surly going to be WAYYYYY WAYYYYY WAYYYYY to complex -> to be able to figure stuff out... Not that you CANT but you might want to consider

Express first just to get an understanding of how a backend works -> without having to plan out all your dtos' controllers services yatta yatta yatta.. you can do all of the same stuff with express, infact the developers used express to make next -> and then added a whole lot of enterprise level stuff that doesnt come standard with express.

plus if you are new to coding then typescript might be a bit much. very sorry if this was not what you were looking for Im not trying to steer you in any particular direction. but I spend 12 hours - 36 hours sometimes trying to figure things out that I already had working before ... the injection and all that come with nest is good , but if you dont know why you need it , then its going to be very hard to actually learn the concepts.

its alot easier to teach someone how to drink water if theyre thirsty .

otherwise you are just going to spend alot of time that could of went into learning the things that are a prerequisite of nest

strong es6 / ts is def a must

the es6 part is more important imo because dealing with everything async for instance and the way everything is formatted its very confusing without a strong grasp of whats going on behind the scenes.

--- as im sure your going to want to find out the hard way -> and i dont blame you if you can get through it you will be a much stronger person =) but here try this on for size.

https://www.npmjs.com/package/nest-influxdb

import { Module } from "@nestjs/common";
import { InfluxDbModule, InfluxModuleOptions } from "nest-influxdb";
import { UtilsModule } from "./utils/utils.module";
import { ConfigService } from "./utils/config/config.service";
 
@Module({
    imports: [
        InfluxDbModule.forRootAsync({
            imports: [UtilsModule],
            inject: [ConfigService],
            useFactory: async (
                config_servie: ConfigService
            ): Promise<InfluxModuleOptions> => {
                return {
                    host: config_servie.get("INFLUX_HOST")
                };
            }
        }),
        BlogModule
    ],
    controllers: [AppController],
    providers: [AppService]
})
export class AppModule {}

this will go in your root level module file -> then you will use the for feature method for the specific thing inside your root database

check the nest docs for how it works with other databases then try to connect the dots with that above package

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文