小编And*_*per的帖子

MongoError:此 MongoDB 部署不支持可重试写入。请将 retryWrites=false 添加到您的连接字符串

"mongoose": "^5.7.1"在我的 Node.js 项目中使用。我正在制作一个涉及更新两个文档的 api。所以,我正在使用如下交易:

// Start the transaction
session = await mongoose.startSession()
session.startTransaction()

await Promise.all([
   <1st update operation>,
   <2nd update operation>
])

// Commit the transaction
session.commitTransaction()
Run Code Online (Sandbox Code Playgroud)

当我在本地环境中点击此 api 时,出现以下错误:

MongoError:此 MongoDB 部署不支持可重试写入。请将 retryWrites=false 添加到您的连接字符串。

当我在远程环境中点击这个 api 时,它运行良好。我使用https://www.clever-cloud.com作为数据库云和 AWS 作为 api 云。

正如错误消息中所写,我试图把 retryWrites=false

  • 在我传递给猫鼬的连接字符串的末尾 mongodb://${ip}:${port}/${this.MONGO_DATABASE}?retryWrites=false
  • 带有retryWrites: false传递给mongoose.connect方法的选项。
mongoose.connect(`mongodb://${ip}:${port}/${this.MONGO_DATABASE}`, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    useCreateIndex: true,
    retryWrites: false
  }, (err) => {...})
Run Code Online (Sandbox Code Playgroud)

以上都没有解决问题。

下面是mongo --version命令的输出:

db version v4.0.13
git …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb

26
推荐指数
3
解决办法
2万
查看次数

是否可以使用 SwiftUI 将键盘上的“返回”键更改为“完成”?

在 SwiftUI 中为 TextField 打开键盘时,我没有找到任何将“返回”键更改为“完成”的链接或指南。

现在可以不自定义 UITextField 吗?

swift swiftui

9
推荐指数
5
解决办法
8231
查看次数

如何根据其子视图高度设置堆栈视图高度?

我需要滚动六种不同类型的视图,每个视图都有不同的大小,其中一个视图是:关于我。在关于我,我必须显示标题(即关于我)和它下面的文字,标签高度应该根据文字高度。

到目前为止,我已将此要求设计为:

根视图 - 堆栈视图 * 项目 1 具有固定高度 * 项目 2 具有固定高度 * UIView 作为关于我: - 标签为标题 - 标签为文本,最大行数设置为 0,宽度等于容器宽度。

问题是:我无法设置关于我的 UIView 的固定高度,并且它不会根据标签文本调整大小。请提出适当的解决方案。

xcode ios swift

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

如何在 SwiftUI 中滚动滚动视图以使 TextField 移动到键盘上方?

我设置了一个 UI,其中有 6 个字段,如下ScrollView所示:

...
         ScrollView {

                IndicatorTextField(
                    index: 0,
                    hint: "Full Name",
                    icon: .imageUserBlue,
                    activeFieldTag: self.$activeFieldTag,
                    type: .alphabet
                ).padding(.top, 48)

                IndicatorTextField(
                    index: 1,
                    hint: "Email Address",
                    icon: .imageEmail,
                    activeFieldTag: self.$activeFieldTag,
                    type: .emailAddress
                ).padding(.top, 8)

                IndicatorTextField(
                    index: 2,
                    hint: "Home Town",
                    icon: .imageLocation,
                    activeFieldTag: self.$activeFieldTag,
                    type: .alphabet
                ).padding(.top, 8)

                IndicatorTextField(
                    index: 3,
                    hint: "Password",
                    icon: .imageLock,
                    activeFieldTag: self.$activeFieldTag,
                    indicatorColor: .reddishPink
                ).padding(.top, 8)

                IndicatorTextField(
                    index: 4,
                    hint: "Date of Birth",
                    icon: .imageCalender,
                    activeFieldTag: self.$activeFieldTag,
                    type: .numbersAndPunctuation,
                    indicatorColor: .reddishPink
                ).padding(.top, …
Run Code Online (Sandbox Code Playgroud)

ios swift swiftui swiftui-list

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

如何使用 UrlSession.DataTaskPublisher 调用发布 Web 服务?

我有一个简单的问题,我只能dataTaskPublisher在能够调用 get web 服务的文档中看到,但是如何调用可以返回发布者的 post web 服务?

swift combine

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

如何修复从底部切割的字体?

我在应用程序中有自定义字体,我在 a 上使用它Text,如下所示:

struct CustomButton: View {

    var label: String
    var action: () -> Void

    init(_ label: String, action: @escaping () -> Void) {
        self.label = label
        self.action = action
    }

    var body: some View {
        Button(action: action) {
            Text(label)
                .padding()
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

预览是:

struct CustomButton_Previews: PreviewProvider {
    static var previews: some View {
        VStack {
            CustomButton("Simple g Button") {
            }
            .font(.custom("NexaBold", size: 40))
            .foregroundColor(.red)
        }
        .background(Color.black)
        .previewDevice(PreviewDevice(rawValue: "iPhone 8"))
    }
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

正如你所看到的,角色g没有很好地显示出来,从底部剪下来。我已经在字体文件中验证它是完整的,但Text显示它是从底部剪下来的。 …

swift swiftui

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

标签 统计

swift ×5

swiftui ×3

ios ×2

combine ×1

mongodb ×1

mongoose ×1

swiftui-list ×1

xcode ×1