Skip to content

Commit

Permalink
Merge b3cde6a into 4bbb3c6
Browse files Browse the repository at this point in the history
  • Loading branch information
tywalch committed Nov 28, 2022
2 parents 4bbb3c6 + b3cde6a commit e05e967
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Expand Up @@ -285,4 +285,8 @@ All notable changes to this project will be documented in this file. Breaking ch

## [2.3.2] - 2022-11-23
### Fixed
- Upsert method would silently disregard `where` clause usage, and would not add condition expression to parameters.
- Upsert method would silently disregard `where` clause usage, and would not add condition expression to parameters.

## [2.3.3] - 2022-11-28
### Fixed
- Issue #182: Addressed inconsistency with `remove` and `delete` functionality between `update` and `patch` methods.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "electrodb",
"version": "2.3.2",
"version": "2.3.3",
"description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/clauses.js
Expand Up @@ -298,7 +298,7 @@ let clauses = {
return state;
}
},
children: ["set", "append", "remove", "add", "subtract", "data"],
children: ["set", "append","updateRemove", "updateDelete", "add", "subtract", "data"],
},
update: {
name: "update",
Expand Down
57 changes: 56 additions & 1 deletion test/ts_connected.update.spec.ts
Expand Up @@ -2461,7 +2461,7 @@ describe("Update Item", () => {
expect(dataRemoveError.message).to.equal(`Attribute "createdAt" is Read-Only and cannot be updated - For more detail on this error reference: https://github.com/tywalch/electrodb#invalid-attribute`);
});

it("should remove properties from an item", async () => {
it("should remove properties from an item via the update method", async () => {
const repoName = uuid();
const repoOwner = uuid();
const createdAt = "2021-07-01";
Expand Down Expand Up @@ -2516,6 +2516,61 @@ describe("Update Item", () => {
});
});

it("should remove properties from an item via the patch method", async () => {
const repoName = uuid();
const repoOwner = uuid();
const createdAt = "2021-07-01";
await repositories
.put({
repoName,
repoOwner,
createdAt,
isPrivate: false,
license: "apache-2.0",
description: "my description",
recentCommits: [
{
sha: "8ca4d4b2",
data: "1627158426",
message: "fixing bug"
},
{
sha: "25d68f54",
data: "1627158100",
message: "adding bug"
}
],
stars: 10,
defaultBranch: "main",
tags: ["tag1", "tag2"]
})
.go();

await repositories
.patch({repoName, repoOwner})
.remove([
"license",
"description",
"recentCommits",
"stars",
"defaultBranch",
"tags",
])
.go();

const item = await repositories
.get({repoName, repoOwner})
.go().then(res => res.data);

expect(item).to.deep.equal({
createdAt,
repoOwner,
repoName,
username: repoOwner,
isPrivate: false,
});
});

it("should remove properties from an item with data method", async () => {
const repoName = uuid();
const repoOwner = uuid();
Expand Down

0 comments on commit e05e967

Please sign in to comment.