Hi,
I’m starting to write some partial bindings for the aws-sdk and I’m already stuck!
The SDK for DynamoDb offers two APIs:
- the
DynamoDb
class - the
DynamoDb.DocumentClient
class
(The difference between the two isn’t relevant to the question but relates to how you supply attribute values.)
In the first case I am able to write:
module DynamoDb = struct
type t [@@bs.deriving abstract]
external create : unit -> t =
"DynamoDB" [@@bs.module "aws-sdk"] [@@bs.new]
end
When used as:
let ddb = BsAwsSdk.DynamoDB.create()
this creates the correct JS fragment:
var AwsSdk = require("aws-sdk");
var db = new AwsSdk.DynamoDB();
However, I’m at a loss for what to write for the second. Given the following usage:
let client = BsAwsSdk.DynamoDB.DocumentClient.create()
I want to generate this JS:
var AwsSdk = require('aws-sdk');
var client = new AwsSdk.DynamoDB.DocumentClient();
I have tried both of the following:
module DynamoDb = struct
module DocumentClient = struct
type t [@@bs.deriving abstract]
external create : unit -> t =
"DynamoDB.DocumentClient" [@@bs.module "aws-sdk"] [@@bs.new]
end
end
and
module DynamoDb = struct
module DocumentClient = struct
type t [@@bs.deriving abstract]
external create : unit -> t =
"DocumentClient" [@@bs.module "aws-sdk.DynamoDb"] [@@bs.new]
end
end
But both are incorrect.
How should I write this in Bucklescript?
Thanks,
Michael