有没有办法使用AQL从集合中随机返回文档?
我想为测试目的创建一个随机图.我还没有弄清楚如何从集合中随机选择文档.
我希望我能做这样的事情:
db._query('RETURN nodes[RAND(0..LENGTH(nodes))]').toArray()
JavaScript exception in file '/usr/share/arangodb/js/client/modules/org/arangodb/arangosh.js' at 104,11: [ArangoError 1541: invalid number of arguments for function 'RAND()', expected number of arguments: minimum: 0, maximum: 0 (while parsing)]
! throw new ArangoError(requestResult);
Run Code Online (Sandbox Code Playgroud)
有关如何做到这一点的任何想法?
我正在使用橡胶部署到EC2(遵循Railscast#347).我刚刚运行"cap rubber:create_staging"并收到此错误:
"Groups belonging to other users may not be granted permissions to VPC security groups."
mike@sleepycat:~/projects/usesthis? cap rubber:create_staging
Respawning with 'bundle exec'
triggering load callbacks
* 2013-08-19 08:55:19 executing `rubber:init'
* 2013-08-19 08:55:21 executing `rubber:create_staging'
Hostname to use for staging instance [production]:
Roles to use for staging instance [apache,app,collectd,common,db:primary=true,elasticsearch,examples,graphite_server,graphite_web,graylog_elasticsearch,graylog_mongodb,graylog_server,graylog_web,haproxy,mongodb,monit,passenger,postgresql,postgresql_master,web,web_tools]:
* 2013-08-19 08:55:23 executing `rubber:create'
* Creating new security group: usesthis_production_default
* Creating new rule: {"source_group_name"=>"usesthis_production_default", "source_group_account"=>"9050-9101-9552"}
/home/mike/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/excon-0.25.3/lib/excon/middlewares/expects.rb:6:in `response_call': InvalidParameterValue => Groups belonging to other users may not be granted …Run Code Online (Sandbox Code Playgroud) 我试图从这个答案做一个查询的变化.我希望能够进一步过滤顶点,这样我就可以自定义前十名(让它成为给定年份中角色最多的十大演员或类似的东西).
如果我尝试使用NEIGHBORS功能,我会收到以下错误:
arangosh [_system]> db._createStatement({query: 'FOR vert IN imdb_vertices FILTER vert.type == "Person" LET edge_count = (LENGTH(NEIGHBORS(imdb_vertices, imdb_edges, vert, "outbound", [{"type": "Role", "$label": "ACTS_IN"}]))) SORT edge_count DESC LIMIT 10 RETURN {"name": vert.name, "count": edge_count}'}).execute().toArray()
JavaScript exception in file '/usr/share/arangodb/js/client/modules/org/arangodb/arangosh.js' at 101,13: TypeError: TypeError: Object #<ShapedJson> has no method 'indexOf'
! throw new TypeError(requestResult.errorMessage);
! ^
stacktrace: TypeError: TypeError: Object #<ShapedJson> has no method 'indexOf'
at Object.exports.checkRequestResult (/usr/share/arangodb/js/client/modules/org/arangodb/arangosh.js:101:13)
at ArangoStatement.execute (/usr/share/arangodb/js/client/modules/org/arangodb/arango-statement.js:171:12)
at (shell):1:290
Run Code Online (Sandbox Code Playgroud)
由于NEIGHBORS似乎返回边和顶点(与返回边的EDGES不同),我认为问题可能是这样,所以我尝试使用TRAVERSAL路径:false选项.不幸的是它给出了同样的错误:
db._createStatement({query: 'FOR vert IN imdb_vertices …Run Code Online (Sandbox Code Playgroud) 如果我需要将数据库"foo"的内容复制到MySQL的第二个数据库"bar"中,我通常会这样做:
mysqldump -u root foo > foo.sql
mysql -u root -e "CREATE DATABASE bar;"
mysql -u root bar < foo.sql
Run Code Online (Sandbox Code Playgroud)
与ArangoDB相同的程序是什么?
我一直在使用Scheme约10分钟,偶然发现了这个错误:
scheme@(guile-user) [2]> (define (a one two) ((* one two)))
scheme@(guile-user) [2]> (a 2 3)
ERROR: In procedure 6:
ERROR: Wrong type to apply: 6
Run Code Online (Sandbox Code Playgroud)
我期待这回到6.如何"申请"进入这个?这个错误是什么意思?
我和我的朋友正在一起开始一个Rails项目并在Github上主持回购.
我/我们应该如何使用我们的数据库凭据来确保我们不公开发布它们或破坏彼此的database.yml设置?
我非常了解红宝石,并从一些玩具程序开始自学C语言.这个只是计算我作为参数输入的一串数字的平均值.
#include <stdio.h>
#include <string.h>
main(int argc, char *argv[])
{
char *token;
int sum = 0;
int count = 0;
token = strtok(argv[1],",");
while (token != NULL)
{
count++;
sum += (int)*token;
token = strtok(NULL, ",");
}
printf("Avg: %d", sum/count);
printf("\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出是:
mike@sleepycat:~/projects/cee$ ./avg 1,1
Avg: 49
Run Code Online (Sandbox Code Playgroud)
这显然需要一些调整.
任何改进和解释将不胜感激.