小编spy*_*nda的帖子

NestJS - 如何在主应用程序模块文件中使用 .env 变量进行数据库连接

我正在开发我的第一个 NestJS 应用程序,它在app.module.ts.

但是根据我们的要求,我不得不从环境文件中选择数据库配置值。为此,我遵循了 nestjs 文档网站上的配置文档 - https://docs.nestjs.com/techniques/configuration

但问题是我需要在同一个文件中使用 .env 变量进行数据库连接,这是失败的。

这是我运行良好的原始代码:

@Module({
  imports: [
    MongooseModule.forRoot(`mongodb+srv://myusername:mypassword@myhost.net?retryWrites=true&w=majority&db=dbname`, { useNewUrlParser: true, dbName: 'dbname' }),
    ProductModule,
    CategoryModule,
  ],
  controllers: [
    AppController,
    HealthCheckController,
  ],
  providers: [AppService, CustomLogger],
})
Run Code Online (Sandbox Code Playgroud)

现在,我想从.ENV文件,这是喜欢挑选那些DB值local.envdev.env取决于环境等。现在,我的这段代码不起作用:

@Module({
  imports: [
    ConfigModule.forRoot({ envFilePath: `${process.env.NODE_ENV}.env` }),
    MongooseModule.forRoot(`mongodb+srv://${ConfigModule.get('DB_USER')}:${ConfigModule.get('DB_PASS')}@myhost.net?retryWrites=true&w=majority&db=dbname`, { useNewUrlParser: true, dbName: 'dbname' }),
    ProductModule,
    CategoryModule,
  ],
  controllers: [
    AppController,
    HealthCheckController,
  ],
  providers: [AppService, CustomLogger],
})
Run Code Online (Sandbox Code Playgroud)

javascript environment-variables node.js nestjs dotenv

23
推荐指数
5
解决办法
2万
查看次数

将 dask.array 列添加到 dask.dataframe

我有一个 dask 数据框和一个 dask 数组,它们的行数相同,逻辑顺序相同。数据帧行由字符串索引。我正在尝试将数组列之一添加到数据框中。我尝试了几种方法,但都以它们特定的方式失败了。

df['col'] = da.col
# TypeError: Column assignment doesn't support type Array

df['col'] = da.to_frame(columns='col')
# TypeError: '<' not supported between instances of 'str' and 'int'

df['col'] = da.to_frame(columns=['col']).set_index(df.col).col
# TypeError: '<' not supported between instances of 'str' and 'int'

df = df.reset_index()
df['col'] = da.to_frame(columns='col')
# ValueError: Not all divisions are known, can't align partitions. Please use `set_index` to set the index.
Run Code Online (Sandbox Code Playgroud)

和其他一些变体。

当结构在逻辑上兼容时,将 dask 数组列添加到 dask 数据帧的正确方法是什么?

python dataframe dask

8
推荐指数
1
解决办法
2624
查看次数

在 Flutter 中创建私有路由

如何对我的私人路线进行包装,仅在用户获得授权时导航到屏幕,否则重定向到登录并在登录后返回原始屏幕。如何以通用的方式实现这一点,以便我在其他私人未来屏幕上重用它?

dart flutter flutter-redux

5
推荐指数
1
解决办法
684
查看次数

如何将行内的容器拉伸到最大可用高度?

我有一个 Row 小部件,其中有许多容器,其高度取决于其内容。我希望它们的高度相同。如何在不硬编码其值的情况下实现这一目标?

这是我有的东西。 在此输入图像描述

但我希望第一张卡自动获取行的高度。这样两张卡的高度就相同。我怎样才能实现这个目标?

这是卡容器的代码:

Widget build(BuildContext context) {
    final statusMap = statusOptionView();
    return Container(
      width: 200,
      margin: EdgeInsets.only(right: 20.0),
      child: Stack(
        children: <Widget>[
          Container(
            padding: EdgeInsets.only(
                left: 20.0, right: 20.0, top: 20.0, bottom: 50.0),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(20.0)),
              color: Color(0xFFF97F8B),
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Row(
                  children: <Widget>[
                    Icon(
                      Icons.access_time,
                      color: Colors.white,
                    ),
                    SizedBox(width: 4.0),
                    Text(
                      event.startTime,
                      style: TextStyle(
                        color: Colors.white,
                      ),
                    )
                  ],
                ),
                SizedBox(
                  height: 20.0,
                ),
                Text(
                  event.title,
                  style: TextStyle(
                    fontWeight: FontWeight.w600,
                    fontSize: …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout

5
推荐指数
2
解决办法
3900
查看次数

多行推送通知颤动

我正在使用 flutter_local_notifications 包进行推送通知。但在通知托盘中,我想显示完整的消息,无论需要多少行。这是我写的代码

void showNotification(message) async {
    var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
      Platform.isAndroid ? 'com.headstrt.app' : 'com.headstrt.app',
      'Flutter chat demo',
      'your channel description',
      playSound: true,
      enableVibration: true,
      importance: Importance.Max,
      priority: Priority.High,
      styleInformation: BigTextStyleInformation(''),
    );

Run Code Online (Sandbox Code Playgroud)

我也指定了样式,但仍然没有显示所有行。

在此输入图像描述

dart flutter

4
推荐指数
1
解决办法
3671
查看次数

无法更改 &lt;DrawerItem&gt; react-native 中标签的颜色

在此处输入图片说明

正如代码中给出的那样,我已经尝试过,我想知道抽屉中显示的“主页”是否会偶然变为白色?

<Drawer.Section style={{backgroundColor:"green"}}>
            <DrawerItem 
              icon={({ color, size }) => (
                <Icon name="home-outline" color={"white"} size={size}/>
              )}
              label="Home"
              color="white" //as this is not working
              onPress={() => {
                props.navigation.navigate("Home");
              }}
            />
    </Drawer.Section>
Run Code Online (Sandbox Code Playgroud)

reactjs react-native

3
推荐指数
1
解决办法
1049
查看次数

React JS 如何在 Hook 中的页面之间传递数据(useEffect)

我试图将一个数据对象传递到另一页,但我无法获取第二页上的数据。下面的代码是我正在使用

第一页通过LINK中的数据

 <Link to={{ pathname: `${path}/users/${organization.id}`,
                                            data: organization
                                        }}>  <img src={config.s3Bucket + "/" + organization.logo} />
 </Link >
Run Code Online (Sandbox Code Playgroud)

在这里,我在“数据”参数中传递对象

第二页

import React, { useState, useEffect } from 'react';
function UserList({ history, match }) {
const { path } = match;
const { id } = match.params;
const [organization, setOrganization] = useState(null);

// const { data } = this.props.location

useEffect(() => {
    
    // console.log(location.data);

}, []);  }   export { UserList };
Run Code Online (Sandbox Code Playgroud)

我已经尝试了 'location.data' 和 'this.props.location' 但我无法获取数据,请帮我解决这个问题。

reactjs react-hooks

2
推荐指数
1
解决办法
3610
查看次数

日期选择器未在 TextFormField 中设置输入

请参阅https://dartpad.dev/c8fc4e640c882616c372653c92362b17上的问题

Datepicker 正在打开并设置状态中的日期,但所选日期在 TextFormField 中不可见。有什么解决办法吗?

dart flutter

1
推荐指数
1
解决办法
4560
查看次数