Skip to content

Commit

Permalink
dynamoose: lib: fix typos
Browse files Browse the repository at this point in the history
Signed-off-by: Mostafa Talaat <mostafatalaat770@gmail.com>
  • Loading branch information
Mostafatalaat770 committed Dec 23, 2022
1 parent 6555d5a commit 9f8f583
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions packages/dynamoose/lib/General.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ interface ModelItemConstructor<T extends Item> {
* });
* console.log(myUser.id); // 1
*
* // myUser is now a item instance of the User model
* // myUser is now an item instance of the User model
* ```
*/
new (object: {[key: string]: any}): T;
Model: Model<T>;
}
export type ModelType<T extends Item> = T & Model<T> & ModelItemConstructor<T>;

// This represents a item array. This is used for the output of functions such as `scan`, `query`, and `batchGet`. These functions can extend this property to add additional properties or functions. However this represents the shared properties/functions for all item arrays.
// This represents an item array. This is used for the output of functions such as `scan`, `query`, and `batchGet`. These functions can extend this property to add additional properties or functions. However this represents the shared properties/functions for all item arrays.
export interface ItemArray<T> extends Array<T> {
populate: () => Promise<ItemArray<T>>;
toJSON: () => ObjectType;
Expand Down
16 changes: 8 additions & 8 deletions packages/dynamoose/lib/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class Item extends InternalPropertiesClass<ItemInternalProperties> {
}

/**
* This function returns a JSON object representation of the item. This is most commonly used when comparing a item to an object you receive elsewhere without worrying about prototypes.
* This function returns a JSON object representation of the item. This is most commonly used when comparing an item to an object you receive elsewhere without worrying about prototypes.
*
* ```js
* const user = new User({"id": 1, "name": "Tim"});
Expand All @@ -143,7 +143,7 @@ export class Item extends InternalPropertiesClass<ItemInternalProperties> {
* console.log(user.toJSON()); // {"id": 1, "name": "Tim"}
* ```
*
* Due to the fact that a item instance is based on an object it is rare that you will have to use this function since you can access all the properties of the item directly. For example, both of the results will yield the same output.
* Due to the fact that an item instance is based on an object it is rare that you will have to use this function since you can access all the properties of the item directly. For example, both of the results will yield the same output.
*
* ```js
* const user = new User({"id": 1, "name": "Tim"});
Expand Down Expand Up @@ -238,7 +238,7 @@ export class Item extends InternalPropertiesClass<ItemInternalProperties> {
}

/**
* This saves a item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
* This saves an item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
*
* This method returns a promise that will resolve when the operation is complete, this promise will reject upon failure. Nothing will be passed into the result for the promise.
*
Expand All @@ -259,7 +259,7 @@ export class Item extends InternalPropertiesClass<ItemInternalProperties> {
*/
save (): Promise<Item>;
/**
* This saves a item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
* This saves an item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
*
* This method returns nothing. It accepts a function into the `callback` parameter. Nothing will be passed into the result for the callback.
*
Expand All @@ -283,7 +283,7 @@ export class Item extends InternalPropertiesClass<ItemInternalProperties> {
*/
save (callback: CallbackType<Item, any>): void;
/**
* This saves a item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
* This saves an item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
*
* This method returns a promise that will resolve when the operation is complete, this promise will reject upon failure. Nothing will be passed into the result for the promise.
*
Expand Down Expand Up @@ -318,7 +318,7 @@ export class Item extends InternalPropertiesClass<ItemInternalProperties> {
*/
save (settings: ItemSaveSettings & {return: "request"}): Promise<DynamoDB.PutItemInput>;
/**
* This saves a item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
* This saves an item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
*
* This method returns a promise that will resolve when the operation is complete, this promise will reject upon failure. You can also pass in a function into the `callback` parameter to have it be used in a callback format as opposed to a promise format. Nothing will be passed into the result for the promise or callback.
*
Expand Down Expand Up @@ -354,7 +354,7 @@ export class Item extends InternalPropertiesClass<ItemInternalProperties> {
*/
save (settings: ItemSaveSettings & {return: "request"}, callback: CallbackType<DynamoDB.PutItemInput, any>): void;
/**
* This saves a item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
* This saves an item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
*
* This method returns a promise that will resolve when the operation is complete, this promise will reject upon failure. You can also pass in a function into the `callback` parameter to have it be used in a callback format as opposed to a promise format. Nothing will be passed into the result for the promise or callback.
*
Expand Down Expand Up @@ -389,7 +389,7 @@ export class Item extends InternalPropertiesClass<ItemInternalProperties> {
*/
save (settings: ItemSaveSettings & {return: "item"}): Promise<Item>;
/**
* This saves a item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
* This saves an item to DynamoDB. This method uses the `putItem` DynamoDB API call to store your object in the given table associated with the model. This method is overwriting, and will overwrite the data you currently have in place for the existing key for your table.
*
* This method returns a promise that will resolve when the operation is complete, this promise will reject upon failure. You can also pass in a function into the `callback` parameter to have it be used in a callback format as opposed to a promise format. Nothing will be passed into the result for the promise or callback.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/dynamoose/lib/Model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ interface ModelInternalProperties {
// Model represents a single entity (ex. User, Movie, Video, Order)
export class Model<T extends ItemCarrier = AnyItem> extends InternalPropertiesClass<ModelInternalProperties> {
/**
* This method is the basic entry point for creating a model in Dynamoose. When you call this method a new model is created, and it returns a Item initializer that you can use to create instances of the given model.
* This method is the basic entry point for creating a model in Dynamoose. When you call this method a new model is created, and it returns an item initializer that you can use to create instances of the given model.
*
* The `name` parameter is a string representing the model name.
*
Expand Down
8 changes: 4 additions & 4 deletions packages/dynamoose/lib/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ interface AttributeDefinition {
*/
enum?: ValueType[];
/**
* You can use a get function on an attribute to be run whenever retrieving a item from DynamoDB. This function will only be run if the item exists in the item. Dynamoose will pass the DynamoDB value into this function and you must return the new value that you want Dynamoose to return to the application.
* You can use a get function on an attribute to be run whenever retrieving an item from DynamoDB. This function will only be run if the item exists in the item. Dynamoose will pass the DynamoDB value into this function and you must return the new value that you want Dynamoose to return to the application.
*
* ```js
* {
Expand All @@ -601,7 +601,7 @@ interface AttributeDefinition {
*/
get?: (value: ValueType) => ValueType;
/**
* You can use a set function on an attribute to be run whenever saving a item to DynamoDB. It will also be used when retrieving an item based on this attribute (ie. `get`, `query`, `update`, etc). This function will only be run if the attribute exists in the item. Dynamoose will pass the value you provide into this function and you must return the new value that you want Dynamoose to save to DynamoDB.
* You can use a set function on an attribute to be run whenever saving an item to DynamoDB. It will also be used when retrieving an item based on this attribute (ie. `get`, `query`, `update`, etc). This function will only be run if the attribute exists in the item. Dynamoose will pass the value you provide into this function and you must return the new value that you want Dynamoose to save to DynamoDB.
*
* ```js
* {
Expand Down Expand Up @@ -885,8 +885,8 @@ export class Schema extends InternalPropertiesClass<SchemaInternalProperties> {
* |---|---|---|---|
* | `saveUnknown` | array \| boolean | false | This setting lets you specify if the schema should allow properties not defined in the schema. If you pass `true` in for this option all unknown properties will be allowed. If you pass in an array of strings, only properties that are included in that array will be allowed. If you pass in an array of strings, you can use `*` to indicate a wildcard nested property one level deep, or `**` to indicate a wildcard nested property infinite levels deep (ex. `["person.*", "friend.**"]` will allow you store a property `person` with 1 level of unknown properties and `friend` with infinitely nested level unknown properties). If you retrieve items from DynamoDB with `saveUnknown` enabled, all custom Dynamoose types will be returned as the underlying DynamoDB type (ex. Dates will be returned as a Number representing number of milliseconds since Jan 1 1970).
* | `timestamps` | boolean \| object | false | This setting lets you indicate to Dynamoose that you would like it to handle storing timestamps in your items for both creation and most recent update times. If you pass in an object for this setting you must specify two keys `createdAt` & `updatedAt`, each with a value of a string or array of strings being the name of the attribute(s) for each timestamp. You can also set each of the `createdAt` & `updatedAt` properties equal to a Schema object. The keys of this Schema object represent the name of the attributes, with the value allowing for customization such as changing the storage type of the date. If you pass in `null` for either of those keys that specific timestamp won't be added to the schema. If you set this option to `true` it will use the default attribute names of `createdAt` & `updatedAt`.
* | `get` | function \| async function | undefined | You can use a get function on the schema to be run whenever retrieving a item from DynamoDB. Dynamoose will pass the entire item into this function and you must return the new value of the entire object you want Dynamoose to return to the application. This function will be run after all property `get` functions are run.
* | `set` | function \| async function | undefined | You can use a set function on the schema to be run whenever saving a item to DynamoDB. It will also be used when retrieving an item (ie. `get`, `query`, `update`, etc). Dynamoose will pass the entire item into this function and you must return the new value of the entire object you want Dynamoose to save to DynamoDB. This function will be run after all property `set` functions are run.
* | `get` | function \| async function | undefined | You can use a get function on the schema to be run whenever retrieving an item from DynamoDB. Dynamoose will pass the entire item into this function and you must return the new value of the entire object you want Dynamoose to return to the application. This function will be run after all property `get` functions are run.
* | `set` | function \| async function | undefined | You can use a set function on the schema to be run whenever saving an item to DynamoDB. It will also be used when retrieving an item (ie. `get`, `query`, `update`, etc). Dynamoose will pass the entire item into this function and you must return the new value of the entire object you want Dynamoose to save to DynamoDB. This function will be run after all property `set` functions are run.
* | `validate` | function \| async function | undefined | You can use a validate function on the schema to ensure the value passes a given validation before saving the item. Dynamoose will pass the entire item into this function and you must return a boolean (`true` if validation passes or `false` if validation fails) or throw an error. This function will be run after all property `validate` functions are run.
*
* ```js
Expand Down
2 changes: 1 addition & 1 deletion packages/dynamoose/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Table.defaults = {

export = {
/**
* This method is the basic entry point for creating a model in Dynamoose. When you call this method a new model is created, and it returns a Item initializer that you can use to create instances of the given model.
* This method is the basic entry point for creating a model in Dynamoose. When you call this method a new model is created, and it returns an item initializer that you can use to create instances of the given model.
*
* The `name` parameter is a string representing the table name that will be used to store items created by this model.
*
Expand Down

0 comments on commit 9f8f583

Please sign in to comment.