Browse Source

代码修改

erlArango_v1
AICells 5 years ago
parent
commit
4a696cc69c
4 changed files with 43 additions and 5 deletions
  1. +5
    -1
      include/erlArango.hrl
  2. +4
    -0
      src/arangoApi/agCollections.erl
  3. +31
    -4
      src/arangoApi/agDbMgr.erl
  4. +3
    -0
      src/httpCli/test.erl

+ 5
- 1
include/erlArango.hrl View File

@ -1,2 +1,6 @@
%% agency %% agency
-define(agAgencyPoolMgr, agAgencyPoolMgr).
-define(agAgencyPoolMgr, agAgencyPoolMgr).
-define(Get, <<"GET">>).
-define(Post, <<"POST">>).
-define(Delete, <<"DELETE">>).

+ 4
- 0
src/arangoApi/agCollections.erl View File

@ -0,0 +1,4 @@
-module(agCollections).
%% API
-export([]).

+ 31
- 4
src/arangoApi/agDbMgr.erl View File

@ -1,11 +1,38 @@
-module(agDbMgr). -module(agDbMgr).
-include("erlArango.hrl").
-export([]).
-compile(export_all).
%% _system访访 %% _system访访
%% %%
% GET /_api/database/current
dbCurrent(PoolName) ->
ok.
%% GET /_api/database/current
curDbInfo(PoolName) ->
agHttpCli:callAgency(PoolName, ?Get, <<"/_api/database/current">>, [], undefined, infinity).
%% 访
%% GET /_api/database/user
userVisitDbs(PoolName) ->
agHttpCli:callAgency(PoolName, ?Get, <<"/_api/database/user">>, [], undefined, infinity).
%% _system数据库中创建新数据库
%% POST /_api/database
% JSON对象是必需的
% name
% users使 root访
% username
% passwd
% activetruefalse
% extraJSON对象Extra中包含的数据 ArangoDB不会进一步解释
newDb(PoolName, Name, Users) ->
NameStr = jsx:encode(#{name => Name}),
UsersStr = jsx:encode(#{users => Users}),
agHttpCli:callAgency(PoolName, ?Post, <<"/_api/database">>, [], [NameStr, UsersStr], infinity).
%%
%% DELETE /_api/database/{database-name}
delDb(PoolName, Name) ->
Path = <<"/_api/database/", Name/binary>>,
agHttpCli:callAgency(PoolName, ?Delete, Path, [], undefined, infinity).

+ 3
- 0
src/httpCli/test.erl View File

@ -3,6 +3,9 @@
-compile([export_all, nowarn_export_all]). -compile([export_all, nowarn_export_all]).
start() ->
application:start(erlArango),
agHttpCli:startPool(tt, [{poolSize, 100}], []).
tt(C, N) -> tt(C, N) ->
application:start(erlArango), application:start(erlArango),

Loading…
Cancel
Save