Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electrodb

Package Overview
Dependencies
Maintainers
1
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electrodb - npm Package Compare versions

Comparing version 0.9.8 to 0.9.9

2

package.json
{
"name": "electrodb",
"version": "0.9.8",
"version": "0.9.9",
"description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -341,8 +341,2 @@ "use strict";

case MethodTypes.patch:
params = this._makeUpdateParams(
update,
keys.pk,
...conlidatedQueryFacets,
);
break;
case MethodTypes.patch:

@@ -383,7 +377,9 @@ params = this._makeUpdateParams(

let facets = this.model.facets.byIndex[indexBase];
let {pk, sk} = this._makeIndexKeys(indexBase);
let keys = this._makeParameterKey(
indexBase,
this._makeKey(this.model.prefixes.pk, facets.pk),
this._makeKey(this.model.prefixes.sk, facets.sk),
pk,
...sk
);
let keyExpressions = this._expressionAttributeBuilder(keys);

@@ -415,6 +411,4 @@ let params = {

let Key = this._makeParameterKey(index, keys.pk, ...keys.sk);
let params = {
Key,
TableName: this.model.table,
};
let TableName = this.model.table;
let params = {Key, TableName};
return params;

@@ -961,2 +955,5 @@ }

this._validateIndex(index);
if (!skFacets.length) {
skFacets.push({});
}
let facets = this.model.facets.byIndex[index];

@@ -963,0 +960,0 @@ let prefixes = this._getPrefixes(facets);

@@ -1087,3 +1087,2 @@ const { Entity, clauses } = require("../src/entity");

let params = MallStores.find({id}).params();
console.log("params", params);
expect(params).to.be.deep.equal({

@@ -1090,0 +1089,0 @@ TableName: 'StoreDirectory',

@@ -703,3 +703,119 @@ const { Service } = require("../src/service");

});
it("Should build the correct pk and sk when the table's pk/sk are part of a collection", async () => {
let modelOne = {
entity: "entityOne",
attributes: {
prop1: {
type: "string",
},
prop2: {
type: "string",
},
prop3: {
type: "string",
},
prop4: {
type: "string",
},
prop5: {
type: "string",
},
prop6: {
type: "string",
},
prop7: {
type: "string",
},
prop8: {
type: "string",
},
prop9: {
type: "string",
},
},
indexes: {
index1: {
pk: {
field: "pk",
facets: ["prop1"],
},
sk: {
field: "sk",
facets: ["prop2", "prop3"],
},
collection: "collectionA",
},
index2: {
pk: {
field: "gsi1pk",
facets: ["prop3"],
},
sk: {
field: "gsi1sk",
facets: ["prop4", "prop5"],
},
collection: "collectionB",
index: "gsi1pk-gsi1sk-index",
},
index3: {
pk: {
field: "gsi2pk",
facets: ["prop5"],
},
sk: {
field: "gsi2sk",
facets: ["prop6", "prop7"],
},
collection: "collectionC",
index: "gsi2pk-gsi2sk-index",
},
index4: {
pk: {
field: "gsi3pk",
facets: ["prop7"],
},
sk: {
field: "gsi3sk",
facets: ["prop8", "prop9"],
},
collection: "collectionD",
index: "gsi3pk-gsi3sk-index",
},
},
};
let database = new Service({version: "1", table: "electro", service: "electrotest"});
database.join(modelOne);
let prop1 = "prop1";
let prop2 = "prop2";
let prop3 = "prop3";
let prop4 = "prop4";
let prop5 = "prop5";
let prop6 = "prop6";
let prop7 = "prop7";
let prop8 = "prop8";
let prop9 = "prop9";
let query = database.entities.entityOne.query.index1({prop1, prop2, prop3}).params();
let scan = database.entities.entityOne.scan.params();
let get = database.entities.entityOne.get({prop1, prop2, prop3}).params();
let destroy = database.entities.entityOne.delete({prop1, prop2, prop3}).params();
let update = database.entities.entityOne.update({prop1, prop2, prop3}).set({prop4, prop5, prop6, prop7, prop8, prop9}).params();
function testKeys(pk, sk) {
if (!pk.startsWith("$electrotest_1#prop1_")) {
throw new Error("Invalid PK");
}
if (!sk.startsWith("$collectiona#entityone#prop2")) {
throw new Error("Invalid SK");
}
}
testKeys(query.ExpressionAttributeValues[":pk"], query.ExpressionAttributeValues[":sk1"]);
testKeys(scan.ExpressionAttributeValues[":pk"], scan.ExpressionAttributeValues[":sk"]);
testKeys(get.Key.pk, get.Key.sk);
testKeys(destroy.Key.pk, destroy.Key.sk);
testKeys(update.Key.pk, update.Key.sk);
});
})
// database.find.collectionA({}).go();

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc