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

Am Freitag, 31. Juli 2020 19:00:36 UTC+2 schrieb Andy:
>
> I try example from 
> https://www.arangodb.com/2017/11/introduction-fuerte-arangodb-c-plus-plus-driver/
> 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
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/arangodb/c81d788e-d3d3-4acc-bb93-6d66bc08e68fo%40googlegroups.com.

Reply via email to