Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: extern typing bug #28

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions dynamo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ const client = new DynamoDBClient({});

// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/PutItemCommand/
export async function _putItem(tableName, item) {
const command = new PutItemCommand({
const putItemInput = {
TableName: tableName,
Item: item,
});
console.log(command);

};
console.log(putItemInput);
const command = new PutItemCommand(putItemInput);
const response = await client.send(command);
console.log(response);
return response;
}

// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/GetItemCommand/
export async function _getItem(tableName, key) {
const command = new GetItemCommand({
const getItemInput = {
TableName: tableName,
Key: key,
});
console.log(command);
};
console.log(getItemInput);
const command = new GetItemCommand(getItemInput);

const response = await client.send(command);
console.log(response);
Expand All @@ -33,10 +34,11 @@ export async function _getItem(tableName, key) {

// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/ScanCommand/
export async function _scan(tableName) {
const command = new ScanCommand({
const scanInput = {
TableName: tableName,
});
console.log(command);
};
console.log(scanInput);
const command = new ScanCommand(scanInput);

const response = await client.send(command);
console.log(response);
Expand Down
4 changes: 2 additions & 2 deletions dynamodb.w
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub class DynamoDBTableAws {
}

extern "./dynamo.js" static inflight _putItem(tableName: str, item: Json): void;
extern "./dynamo.js" static inflight _getItem(tableName: str, key: Json): Map<Map<Map<str>>>;
extern "./dynamo.js" static inflight _getItem(tableName: str, key: Json): Map<Map<Map<str>>>?;
extern "./dynamo.js" static inflight _scan(tableName: str): Map<Array<Map<Map<str>>>>;

pub inflight putItem(item: Map<Attribute>) {
Expand All @@ -104,7 +104,7 @@ pub class DynamoDBTableAws {
pub inflight getItem(key: Map<Attribute>): Map<Attribute> {
let json = this._itemToJson(key);
let result = DynamoDBTableAws._getItem(this.tableName, json);
return this._rawMapToItem(result.get("Item"));
return this._rawMapToItem(result?.get("Item") ?? {});
}

pub inflight scan(): Array<Map<Attribute>> {
Expand Down
Loading