小编EZ-*_*Z-C的帖子

docker:在 M1 Mac 上通过 Docker 安装 ArangoDB 时,没有 linux/arm64/v8 的匹配清单

当您尝试通过 Docker 安装 ArangoDB 时:

docker run -e ARANGO_ROOT_PASSWORD=password -p 8529:8529 -d --name arangodb arangodb

抛出以下错误:

Unable to find image 'arangodb:latest' locally
latest: Pulling from library/arangodb
docker: no matching manifest for linux/arm64/v8 in the manifest list entries.
See 'docker run --help'.
Run Code Online (Sandbox Code Playgroud)

arangodb docker apple-m1

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

Serde json 值省略 None 上的属性

给定以下 JsonValue:

let mut schema = json!({
    "level": "strict",
    "rule": {}
});
Run Code Online (Sandbox Code Playgroud)

我们将动态地将值插入到此 JsonValue 中

let value: json!({
    "type": property.r#type,
    "minLength": property.min_length,
    "maxLength": property.max_length,
    "enum": property.r#enum
});

schema["rule"]
    .as_object_mut()
    .unwrap()
    .insert(
        String::from(property.name), 
        value
    );

// Struct for Property
#[derive(Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SchemaDocumentProperty
{
    pub name: String,
    pub r#type: Option<String>,
    pub min_length: Option<u32>,
    pub max_length: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#enum: Option<Vec<String>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub items: Option<SchemaDocumentPropertyArray>
}
Run Code Online (Sandbox Code Playgroud)

当前输出如下,其中minLengthmaxLengthenum均为 …

rust serde

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

如何在javascript字符串中使用\n

例:

var i = 'Hello \n World'
console.log(i)
Run Code Online (Sandbox Code Playgroud)

会回来:

Hello
World
Run Code Online (Sandbox Code Playgroud)

而且我希望它返回

Hello \n World
Run Code Online (Sandbox Code Playgroud)

不渲染新行,因为我打算将其存储在数据库中.


对于那些想要在数据库中存储的人

您不需要转义,因为您的文档数据库将执行JSON.strigify,我使用ArangoDB并且它工作得非常好,感谢@PaulPro

javascript string arangodb console.log

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

标签 统计

arangodb ×2

apple-m1 ×1

console.log ×1

docker ×1

javascript ×1

rust ×1

serde ×1

string ×1