[fuerte] How to use AttributeTranslator or get attributes after Post?

42 views
Skip to first unread message

Andy

unread,
Jul 31, 2020, 1:00:36 PM7/31/20
to ArangoDB
It compiles, but after
auto request = f::createRequest(f::RestVerb::Post, "/_api/document/blogpost"s);
request->addVPack(builder.slice());
auto result = connection->sendRequest(std::move(request));
std::stirng key=result->slices().front().get("_key").copyString();

is exception: what():  Cannot execute operation without attribute translator
I do (probably badly)
arangodb::velocypack::AttributeTranslator translator;
arangodb::velocypack::Options::Defaults.attributeTranslator = &translator;
and have exception: what():  Expecting type String

I can read slice attributes in
        auto request = f::createRequest(f::RestVerb::Get, "/_api/version"s);
        auto result = connection->sendRequest(std::move(request));
        assert(result->statusCode() == f::StatusOK);
        auto slice = result->slices().front();
        auto version = slice.get("version").copyString();
        auto server = slice.get("server").copyString();

but after f::RestVerb::Post, I can't

Jan

unread,
Aug 1, 2020, 6:55:04 AM8/1/20
to ArangoDB
Hi,

the ArangoDB database uses the AttributeTranslator to translate certain attribute names from strings into one-byte shorthand values.
Receiving a response from an ArangoDB database server may contain these shorthand values, and in order to process them an AttributeTranslator instance has to be set up and configured in the same way.
This can be achieved by the following:

  arangodb::velocypack::AttributeTranslator translator;
  // these attribute names will be translated into short integer values
  translator.add("_key", 1);
  translator.add("_rev", 2);
  translator.add("_id", 3);
  translator.add("_from", 4);
  translator.add("_to", 5);
  translator.seal();

  arangodb::velocypack::Options::Defaults.attributeTranslator = &translator;
   
I hope this helps.
Best regards
Jan

Andy

unread,
Aug 2, 2020, 9:10:21 AM8/2/20
to ArangoDB
This helps, seal() was keyed.

Vaibhav Patil

unread,
Aug 2, 2020, 10:19:10 PM8/2/20
to aran...@googlegroups.com

On Sun, Aug 2, 2020 at 6:40 PM Andy <borucki...@gmail.com> wrote:
This helps, seal() was keyed.

--
You received this message because you are subscribed to the Google Groups "ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arangodb+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arangodb/b900b252-d062-4ada-a47e-8c609936bd44o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages