谷歌宣布了Firestore,这是一个新的文档数据存储区.
我已经使用Google Cloud Datastore开发了一个应用程序超过六个月了,在阅读博客之后,我觉得Firestore似乎是一个更好的选择.
备用集合 - 文档 - 子集合的概念对我来说非常好,因为在为数据存储区设计模式时,我知道我将无法查询嵌套字段.现在使用firestore子集合,我获得了完整的查询功能,这对我来说是一个游戏规则改变者(我可以用最少的查询获得最大数据).
作为反驳论点,流程图建议我使用数据存储区,因为我没有任何移动客户端.
像Datastore一样使用Firestore是个好主意吗?(我会方便地忽略移动客户端/实时更新/同步功能!)
firebase google-cloud-datastore google-cloud-platform google-cloud-firestore
我在请求中得到了一个字符串数组.每个字符串都包含要在本机shell上执行的命令.
var process = require('child_process');
function execCommand(req,res,callback){
var params = req.params.list //list is an array in the request
var result = '';
var command = '';
for (var i = 0; i < params.length; i++) {
command = params[i];
cmd = process.exec(command);
cmd.stdout.on('data', function(data){
//push the shell output in variable result
});
cmd.on('close', function(code) {
//convert the variable result to a valid JSON
});
}
res.send(result);
};
Run Code Online (Sandbox Code Playgroud)
所有命令的结果在result变量中混淆.如何使for循环中的函数调用同步?
我正在节点模块中从 S3 存储桶检索对象。该对象已object.json.gz格式化。我需要将其解压缩,object.json以便能够在节点模块中解析它。以下是代码片段
aws.config.update({ accessKeyId: <my_key>, secretAccessKey: <my_secret_key>, region: <my_region> });
var s3 = new aws.S3();
s3.getObject(
{ Bucket: "<my_bucket>", Key: "<my_file_key>"},
function (error, data) {
if (error != null) {
console.log("Error retrieving the Object from the S3 bucket.")
console.log(error);
} else {
zlib.gunzip(data, function(err, buffer){
if (!err) {
console.log(buffer);
}
else console.log(err);
});
}
}
);
Run Code Online (Sandbox Code Playgroud)
如果我将对象记录data到控制台,它会记录以下内容,
{ AcceptRanges: 'bytes',
LastModified: 'Thu, 04 Jun 2015 17:41:12 GMT',
ContentLength: '12677',
ETag: '"ebb8f339f569b9aea1038c005442eedd"',
ContentEncoding: 'gzip', …Run Code Online (Sandbox Code Playgroud) 我是 golang 的新手。但我找不到答案。
在python中我可以做到,
array = [1, 2, 3, None, 5]
Run Code Online (Sandbox Code Playgroud)
但是当我写的时候
var array = [5]int {1, 2, 3, nil, 5}
Run Code Online (Sandbox Code Playgroud)
编译器给了我以下错误:
cannot convert nil to type int
Run Code Online (Sandbox Code Playgroud)
如何在 golang 中创建一个混合了整数和 nil 值的数组?