dynamoose
Advanced tools
Comparing version 3.0.0-beta.5 to 3.0.0-beta.6
@@ -6,4 +6,4 @@ import * as DynamoDB from "@aws-sdk/client-dynamodb"; | ||
revert: () => void; | ||
local: (endpoint: string) => void; | ||
local: (endpoint?: string) => void; | ||
} | ||
export default function (): DDBInterface; |
@@ -12,3 +12,3 @@ import { Model } from "./Model"; | ||
overwrite?: boolean; | ||
return?: "request" | "Item"; | ||
return?: "request" | "item"; | ||
condition?: Condition; | ||
@@ -83,2 +83,20 @@ } | ||
toJSON(): ObjectType; | ||
/** | ||
* This method will return a promise containing an object of the item that includes default values for any undefined values in the item. | ||
* | ||
* ```js | ||
* const schema = new Schema({ | ||
* "id": String, | ||
* "data": { | ||
* "type": String, | ||
* "default": "Hello World" | ||
* } | ||
* }); | ||
* const User = dynamoose.model("User", schema); | ||
* const user = new User({"id": 1}); | ||
* console.log(await user.withDefaults()); // {"id": 1, "data": "Hello World"} | ||
* ``` | ||
* @returns Promise<Object> | ||
*/ | ||
withDefaults(): Promise<ObjectType>; | ||
serialize(nameOrOptions?: SerializerOptions | string): ObjectType; | ||
@@ -85,0 +103,0 @@ /** |
@@ -112,2 +112,26 @@ "use strict"; | ||
} | ||
/** | ||
* This method will return a promise containing an object of the item that includes default values for any undefined values in the item. | ||
* | ||
* ```js | ||
* const schema = new Schema({ | ||
* "id": String, | ||
* "data": { | ||
* "type": String, | ||
* "default": "Hello World" | ||
* } | ||
* }); | ||
* const User = dynamoose.model("User", schema); | ||
* const user = new User({"id": 1}); | ||
* console.log(await user.withDefaults()); // {"id": 1, "data": "Hello World"} | ||
* ``` | ||
* @returns Promise<Object> | ||
*/ | ||
async withDefaults() { | ||
return Item.objectFromSchema(utils_1.default.deep_copy(this.toJSON()), this.getInternalProperties(internalProperties).model, { | ||
"typeCheck": false, | ||
"defaults": true, | ||
"type": "toDynamo" | ||
}); | ||
} | ||
// Serializer | ||
@@ -114,0 +138,0 @@ serialize(nameOrOptions) { |
@@ -7,3 +7,3 @@ import * as DynamoDB from "@aws-sdk/client-dynamodb"; | ||
revert: () => void; | ||
local: (endpoint: string) => void; | ||
local: (endpoint?: string) => void; | ||
} | ||
@@ -10,0 +10,0 @@ |
@@ -25,3 +25,3 @@ import awsConverter from "./aws/converter"; | ||
overwrite?: boolean; | ||
return?: "request" | "Item"; | ||
return?: "request" | "item"; | ||
condition?: Condition; | ||
@@ -155,2 +155,27 @@ } | ||
/** | ||
* This method will return a promise containing an object of the item that includes default values for any undefined values in the item. | ||
* | ||
* ```js | ||
* const schema = new Schema({ | ||
* "id": String, | ||
* "data": { | ||
* "type": String, | ||
* "default": "Hello World" | ||
* } | ||
* }); | ||
* const User = dynamoose.model("User", schema); | ||
* const user = new User({"id": 1}); | ||
* console.log(await user.withDefaults()); // {"id": 1, "data": "Hello World"} | ||
* ``` | ||
* @returns Promise<Object> | ||
*/ | ||
async withDefaults (): Promise<ObjectType> { | ||
return Item.objectFromSchema(utils.deep_copy(this.toJSON()), this.getInternalProperties(internalProperties).model, { | ||
"typeCheck": false, | ||
"defaults": true, | ||
"type": "toDynamo" | ||
}); | ||
} | ||
// Serializer | ||
@@ -157,0 +182,0 @@ serialize (nameOrOptions?: SerializerOptions | string): ObjectType { |
{ | ||
"name": "dynamoose", | ||
"version": "3.0.0-beta.5", | ||
"version": "3.0.0-beta.6", | ||
"description": "Dynamoose is a modeling tool for Amazon's DynamoDB (inspired by Mongoose)", | ||
@@ -28,9 +28,9 @@ "homepage": "https://dynamoosejs.com", | ||
"dependencies": { | ||
"@aws-sdk/client-dynamodb": "^3.49.0", | ||
"@aws-sdk/util-dynamodb": "^3.49.0", | ||
"dynamoose-utils": "^3.0.0-beta.5", | ||
"@aws-sdk/client-dynamodb": "^3.105.0", | ||
"@aws-sdk/util-dynamodb": "^3.105.0", | ||
"dynamoose-utils": "^3.0.0-beta.6", | ||
"js-object-utilities": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"dynamoose-logger": "^3.0.0-beta.5" | ||
"dynamoose-logger": "^3.0.0-beta.6" | ||
}, | ||
@@ -48,3 +48,3 @@ "license": "Unlicense", | ||
], | ||
"gitHead": "cb548e4c2581483ceeef95c86cfc2d75475db527" | ||
"gitHead": "ff510fc881ddf3b4127e29d0f05b6628f5615acc" | ||
} |
@@ -25,2 +25,4 @@ /* eslint @typescript-eslint/no-unused-vars: 0 */ | ||
const shouldPassCreateWithNoReturnSetting = model.create({"id": 1}, {"overwrite": true}); | ||
const shouldPassCreateWithReturnRequest = model.create({"id": 1}, {"return": "request"}); | ||
const shouldPassCreateWithReturnItem = model.create({"id": 1}, {"return": "item"}); | ||
const shouldPassGetWithNoReturnSetting = model.get({"id": 1}, {"attributes": ["something"]}); | ||
@@ -50,2 +52,5 @@ const shouldPassDeleteWithNoReturnSetting = model.delete({"id": 1}, {"condition": new dynamoose.Condition("name").eq("Charlie")}); | ||
// @ts-expect-error | ||
const shouldFailWithInvalidReturnType = model.create({"id": 1}, {"return": "invalid-return-type"}); | ||
// @ts-expect-error | ||
const shouldFailWithInvalidTransaction = model.transaction.notValid(); | ||
@@ -52,0 +57,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
1336118
198
29566
0
72
0