dynamoose
Advanced tools
Comparing version 3.0.0-beta.8 to 3.0.0-beta.9
@@ -66,4 +66,6 @@ import { Schema, SchemaDefinition } from "./Schema"; | ||
*/ | ||
model: <T extends Item = AnyItem>(name: string, schema?: Schema | SchemaDefinition | (Schema | SchemaDefinition)[]) => ModelType<T>; | ||
Table: import("./Instance").PrimaryTableInterface; | ||
model: <T extends Item = AnyItem>(name: string, schema?: Schema | SchemaDefinition | (Schema | SchemaDefinition)[], options?: import("./General").DeepPartial<import("./Table/index").TableOptions>) => ModelType<T>; | ||
Table: import("./Instance").PrimaryTableInterface & { | ||
defaults: import("./Table/defaults").TableOptionsAccessor; | ||
}; | ||
Instance: typeof Instance; | ||
@@ -70,0 +72,0 @@ Schema: typeof Schema; |
@@ -13,3 +13,4 @@ "use strict"; | ||
const defaults_1 = require("./Table/defaults"); | ||
const model = (name, schema) => { | ||
const returnModel_1 = require("./utils/dynamoose/returnModel"); | ||
const model = (name, schema, options) => { | ||
let model; | ||
@@ -28,42 +29,5 @@ let storedSchema; | ||
else { | ||
model = new Model_1.Model(name, schema, ModelStore_1.default); | ||
model = new Model_1.Model(name, schema, options, ModelStore_1.default); | ||
} | ||
const returnObject = model.Item; | ||
const keys = utils_1.default.array_flatten([ | ||
Object.keys(model), | ||
Object.keys(Object.getPrototypeOf(model)), | ||
Object.getOwnPropertyNames(Object.getPrototypeOf(model)) | ||
]).filter((key) => !["constructor", "name"].includes(key)); | ||
keys.forEach((key) => { | ||
if (typeof model[key] === "object") { | ||
const main = (key) => { | ||
utils_1.default.object.set(returnObject, key, {}); | ||
const value = utils_1.default.object.get(model, key); | ||
if (value === null || value.constructor !== Object && value.constructor !== Array) { | ||
utils_1.default.object.set(returnObject, key, value); | ||
} | ||
else { | ||
Object.keys(value).forEach((subKey) => { | ||
const newKey = `${key}.${subKey}`; | ||
const subValue = utils_1.default.object.get(model, newKey); | ||
if (typeof subValue === "object") { | ||
main(newKey); | ||
} | ||
else { | ||
utils_1.default.object.set(returnObject, newKey, subValue.bind(model)); | ||
} | ||
}); | ||
} | ||
}; | ||
main(key); | ||
} | ||
else { | ||
returnObject[key] = model[key].bind(model); | ||
} | ||
}); | ||
Object.defineProperty(returnObject, "name", { | ||
"configurable": false, | ||
"value": returnObject.Model.name | ||
}); | ||
return returnObject; | ||
return (0, returnModel_1.default)(model); | ||
}; | ||
@@ -70,0 +34,0 @@ index_1.Table.defaults = Object.assign({}, defaults_1.custom); |
import { AWS } from "./aws"; | ||
import { Model } from "./Model"; | ||
import { Table as PrimaryTable, TableOptionsOptional } from "./Table"; | ||
import { TableOptionsAccessor } from "./Table/defaults"; | ||
export interface PrimaryTableInterface extends PrimaryTable { | ||
@@ -10,3 +11,5 @@ new (name: string, models: Model[], options?: TableOptionsOptional): PrimaryTable; | ||
aws: AWS; | ||
Table: PrimaryTableInterface; | ||
Table: PrimaryTableInterface & { | ||
"defaults": TableOptionsAccessor; | ||
}; | ||
/** | ||
@@ -13,0 +16,0 @@ * This class allows you to create a new instance of Dynamoose, allowing for easy multi-region AWS requests. |
@@ -25,3 +25,3 @@ "use strict"; | ||
class Table extends Table_1.Table { | ||
constructor(name, models, options = {}) { | ||
constructor(name, models, options) { | ||
super(instance, name, models, options); | ||
@@ -28,0 +28,0 @@ } |
@@ -9,3 +9,3 @@ import { Schema, SchemaDefinition, IndexItem, TableIndex } from "../Schema"; | ||
import { GetTransactionInput, CreateTransactionInput, DeleteTransactionInput, UpdateTransactionInput, ConditionTransactionInput } from "../Transaction"; | ||
import { Table } from "../Table"; | ||
import { Table, TableOptionsOptional } from "../Table"; | ||
import { InternalPropertiesClass } from "../InternalPropertiesClass"; | ||
@@ -102,2 +102,3 @@ declare type GetTransactionResult = Promise<GetTransactionInput>; | ||
name: string; | ||
options: TableOptionsOptional; | ||
getIndexes: () => Promise<{ | ||
@@ -129,2 +130,4 @@ GlobalSecondaryIndexes?: IndexItem[]; | ||
* | ||
* The `options` parameter is the same as the options that are passed to the [Table](Table.md) constructor. | ||
* | ||
* ```js | ||
@@ -176,7 +179,10 @@ * const dynamoose = require("dynamoose"); | ||
* ``` | ||
* | ||
* If you choose to pass the model into a [`Table`](Table.md) constructor, you must ensure that you don't use the model for any DynamoDB requests before initializing the table. | ||
* @param name The name of the model. | ||
* @param schema The schema for the model. | ||
* @param options The options for the model. This is the same type as `Table` options. | ||
* @param ModelStore INTERNAL PARAMETER | ||
*/ | ||
constructor(name: string, schema: Schema | SchemaDefinition | (Schema | SchemaDefinition)[], ModelStore: (model: Model) => void); | ||
constructor(name: string, schema: Schema | SchemaDefinition | (Schema | SchemaDefinition)[], options: TableOptionsOptional, ModelStore: (model: Model) => void); | ||
/** | ||
@@ -183,0 +189,0 @@ * This property is a string that represents the model name. |
@@ -13,4 +13,7 @@ "use strict"; | ||
const Populate_1 = require("../Populate"); | ||
const Table_1 = require("../Table"); | ||
const type_1 = require("../type"); | ||
const InternalPropertiesClass_1 = require("../InternalPropertiesClass"); | ||
const Instance_1 = require("../Instance"); | ||
const returnModel_1 = require("../utils/dynamoose/returnModel"); | ||
const { internalProperties } = Internal_1.default.General; | ||
@@ -26,2 +29,4 @@ // Model represents a single entity (ex. User, Movie, Video, Order) | ||
* | ||
* The `options` parameter is the same as the options that are passed to the [Table](Table.md) constructor. | ||
* | ||
* ```js | ||
@@ -73,7 +78,10 @@ * const dynamoose = require("dynamoose"); | ||
* ``` | ||
* | ||
* If you choose to pass the model into a [`Table`](Table.md) constructor, you must ensure that you don't use the model for any DynamoDB requests before initializing the table. | ||
* @param name The name of the model. | ||
* @param schema The schema for the model. | ||
* @param options The options for the model. This is the same type as `Table` options. | ||
* @param ModelStore INTERNAL PARAMETER | ||
*/ | ||
constructor(name, schema, ModelStore) { | ||
constructor(name, schema, options, ModelStore) { | ||
super(); | ||
@@ -83,2 +91,3 @@ // Methods | ||
name, | ||
options, | ||
"getIndexes": async () => { | ||
@@ -151,3 +160,6 @@ return (await Promise.all(this.getInternalProperties(internalProperties).schemas.map((schema) => schema.getIndexes(this)))).reduce((result, indexes) => { | ||
if (!table) { | ||
throw new Error_1.default.OtherError(`No table has been registered for ${this.name} model. Use \`new dynamoose.Table\` to register a table for this model.`); | ||
const modelObject = (0, returnModel_1.default)(this); | ||
const createdTable = new Table_1.Table(Instance_1.Instance.default, this.getInternalProperties(internalProperties).name, [modelObject], this.getInternalProperties(internalProperties).options); | ||
this.getInternalProperties(internalProperties)._table = createdTable; | ||
return createdTable; | ||
} | ||
@@ -154,0 +166,0 @@ return table; |
@@ -68,3 +68,3 @@ /// <reference types="node" /> | ||
*/ | ||
type?: IndexType; | ||
type?: IndexType | keyof typeof IndexType; | ||
/** | ||
@@ -71,0 +71,0 @@ * The range key attribute name for a global secondary index. |
import { TableOptions, TableOptionsOptional } from "./index"; | ||
export declare const original: TableOptions; | ||
declare const customObject: { | ||
set: (val: TableOptionsOptional) => void; | ||
get: () => TableOptionsOptional; | ||
}; | ||
export interface TableOptionsAccessor { | ||
"set": (val: TableOptionsOptional) => void; | ||
"get": () => TableOptionsOptional; | ||
} | ||
declare const customObject: TableOptionsAccessor; | ||
export { customObject as custom }; |
@@ -84,3 +84,3 @@ "use strict"; | ||
*/ | ||
constructor(instance, name, models, options) { | ||
constructor(instance, name, models, options = {}) { | ||
super(); | ||
@@ -87,0 +87,0 @@ // Check name argument |
@@ -13,2 +13,3 @@ "use strict"; | ||
const types_1 = require("./types"); | ||
const defaults = require("./defaults"); | ||
// Utility functions | ||
@@ -78,3 +79,5 @@ async function getTableDetails(table, settings = {}) { | ||
async function createTable(table, force = false) { | ||
if (!force && ((await getTableDetails(table, { "allowError": true }) || {}).Table || {}).TableStatus === "ACTIVE") { | ||
var _a, _b; | ||
const tableStatus = (_b = (_a = (await getTableDetails(table, { "allowError": true }))) === null || _a === void 0 ? void 0 : _a.Table) === null || _b === void 0 ? void 0 : _b.TableStatus; | ||
if (!force && tableStatus === "ACTIVE") { | ||
table.getInternalProperties(internalProperties).alreadyCreated = true; | ||
@@ -125,3 +128,5 @@ return () => Promise.resolve.bind(Promise)(); | ||
var _a; | ||
if (typeof table.getInternalProperties(internalProperties).options.waitForActive !== "boolean") { | ||
const waitForActiveSettingValue = table.getInternalProperties(internalProperties).options.waitForActive; | ||
if (typeof waitForActiveSettingValue !== "boolean" || waitForActiveSettingValue === true) { | ||
const waitForActiveSetting = typeof waitForActiveSettingValue === "boolean" ? defaults.original.waitForActive : waitForActiveSettingValue; | ||
try { | ||
@@ -138,5 +143,5 @@ // Normally we'd want to do `dynamodb.waitFor` here, but since it doesn't work with tables that are being updated we can't use it in this case | ||
if (count > 0) { | ||
table.getInternalProperties(internalProperties).options.waitForActive.check.frequency === 0 ? await utils_1.default.set_immediate_promise() : await utils_1.default.timeout(table.getInternalProperties(internalProperties).options.waitForActive.check.frequency); | ||
waitForActiveSetting.check.frequency === 0 ? await utils_1.default.set_immediate_promise() : await utils_1.default.timeout(waitForActiveSetting.check.frequency); | ||
} | ||
if (Date.now() - start >= table.getInternalProperties(internalProperties).options.waitForActive.check.timeout) { | ||
if (Date.now() - start >= waitForActiveSetting.check.timeout) { | ||
return reject(new Error_1.default.WaitForActiveTimeout(`Wait for active timed out after ${Date.now() - start} milliseconds.`)); | ||
@@ -143,0 +148,0 @@ } |
@@ -5,6 +5,6 @@ interface ThroughputSettings { | ||
} | ||
export interface ModelSettings { | ||
export interface TableSettings { | ||
throughput: ThroughputSettings | number | "ON_DEMAND"; | ||
} | ||
declare const _default: (options: Partial<ModelSettings>) => { | ||
declare const _default: (options: Partial<TableSettings>) => { | ||
"BillingMode": "PAY_PER_REQUEST"; | ||
@@ -11,0 +11,0 @@ } | { |
import { itemToJSON } from "./itemToJSON"; | ||
declare const _default: { | ||
get_provisioned_throughput: (options: Partial<import("./get_provisioned_throughput").ModelSettings>) => {} | { | ||
get_provisioned_throughput: (options: Partial<import("./get_provisioned_throughput").TableSettings>) => {} | { | ||
BillingMode: "PAY_PER_REQUEST"; | ||
@@ -5,0 +5,0 @@ } | { |
@@ -19,3 +19,3 @@ import * as object from "js-object-utilities"; | ||
dynamoose: { | ||
get_provisioned_throughput: (options: Partial<import("./dynamoose/get_provisioned_throughput").ModelSettings>) => {} | { | ||
get_provisioned_throughput: (options: Partial<import("./dynamoose/get_provisioned_throughput").TableSettings>) => {} | { | ||
BillingMode: "PAY_PER_REQUEST"; | ||
@@ -22,0 +22,0 @@ } | { |
@@ -10,8 +10,9 @@ import {Model} from "./Model"; | ||
import CustomError from "./Error"; | ||
import {Table} from "./Table/index"; | ||
import {Table, TableOptionsOptional} from "./Table/index"; | ||
import type from "./type"; | ||
import {Instance} from "./Instance"; | ||
import {custom as TableDefaults} from "./Table/defaults"; | ||
import returnModel from "./utils/dynamoose/returnModel"; | ||
const model = <T extends Item = AnyItem>(name: string, schema?: Schema | SchemaDefinition | (Schema | SchemaDefinition)[]): ModelType<T> => { | ||
const model = <T extends Item = AnyItem>(name: string, schema?: Schema | SchemaDefinition | (Schema | SchemaDefinition)[], options?: TableOptionsOptional): ModelType<T> => { | ||
let model: Model<T>; | ||
@@ -29,41 +30,6 @@ let storedSchema: Model<T>; | ||
} else { | ||
model = new Model(name, schema, ModelStore); | ||
model = new Model(name, schema, options, ModelStore); | ||
} | ||
const returnObject: any = model.Item; | ||
const keys = utils.array_flatten([ | ||
Object.keys(model), | ||
Object.keys(Object.getPrototypeOf(model)), | ||
Object.getOwnPropertyNames(Object.getPrototypeOf(model)) | ||
]).filter((key) => !["constructor", "name"].includes(key)); | ||
keys.forEach((key) => { | ||
if (typeof model[key] === "object") { | ||
const main = (key: string): void => { | ||
utils.object.set(returnObject, key, {}); | ||
const value = utils.object.get(model as any, key); | ||
if (value === null || value.constructor !== Object && value.constructor !== Array) { | ||
utils.object.set(returnObject, key, value); | ||
} else { | ||
Object.keys(value).forEach((subKey): void => { | ||
const newKey = `${key}.${subKey}`; | ||
const subValue: any = utils.object.get(model as any, newKey); | ||
if (typeof subValue === "object") { | ||
main(newKey); | ||
} else { | ||
utils.object.set(returnObject, newKey, subValue.bind(model)); | ||
} | ||
}); | ||
} | ||
}; | ||
main(key); | ||
} else { | ||
returnObject[key] = model[key].bind(model); | ||
} | ||
}); | ||
Object.defineProperty(returnObject, "name", { | ||
"configurable": false, | ||
"value": returnObject.Model.name | ||
}); | ||
return returnObject as any; | ||
return returnModel(model); | ||
}; | ||
@@ -70,0 +36,0 @@ Table.defaults = { |
import {AWS} from "./aws"; | ||
import {Model} from "./Model"; | ||
import {Table as PrimaryTable, TableOptionsOptional} from "./Table"; | ||
import {TableOptionsAccessor} from "./Table/defaults"; | ||
@@ -13,3 +14,3 @@ export interface PrimaryTableInterface extends PrimaryTable { | ||
aws: AWS; | ||
Table: PrimaryTableInterface; | ||
Table: PrimaryTableInterface & {"defaults": TableOptionsAccessor}; | ||
@@ -33,3 +34,3 @@ /** | ||
class Table extends PrimaryTable { | ||
constructor (name: string, models: Model[], options: TableOptionsOptional = {}) { | ||
constructor (name: string, models: Model[], options: TableOptionsOptional) { | ||
super(instance, name, models, options); | ||
@@ -36,0 +37,0 @@ } |
@@ -15,5 +15,7 @@ import CustomError from "../Error"; | ||
import {GetTransactionInput, CreateTransactionInput, DeleteTransactionInput, UpdateTransactionInput, ConditionTransactionInput} from "../Transaction"; | ||
import {Table} from "../Table"; | ||
import {Table, TableOptionsOptional} from "../Table"; | ||
import type from "../type"; | ||
import {InternalPropertiesClass} from "../InternalPropertiesClass"; | ||
import {Instance} from "../Instance"; | ||
import returnModel from "../utils/dynamoose/returnModel"; | ||
const {internalProperties} = Internal.General; | ||
@@ -100,2 +102,3 @@ | ||
name: string; | ||
options: TableOptionsOptional; | ||
getIndexes: () => Promise<{GlobalSecondaryIndexes?: IndexItem[]; LocalSecondaryIndexes?: IndexItem[]; TableIndex?: any}>; | ||
@@ -126,2 +129,4 @@ convertObjectToKey: (key: InputKey) => KeyObject; | ||
* | ||
* The `options` parameter is the same as the options that are passed to the [Table](Table.md) constructor. | ||
* | ||
* ```js | ||
@@ -173,7 +178,10 @@ * const dynamoose = require("dynamoose"); | ||
* ``` | ||
* | ||
* If you choose to pass the model into a [`Table`](Table.md) constructor, you must ensure that you don't use the model for any DynamoDB requests before initializing the table. | ||
* @param name The name of the model. | ||
* @param schema The schema for the model. | ||
* @param options The options for the model. This is the same type as `Table` options. | ||
* @param ModelStore INTERNAL PARAMETER | ||
*/ | ||
constructor (name: string, schema: Schema | SchemaDefinition | (Schema | SchemaDefinition)[], ModelStore: (model: Model) => void) { | ||
constructor (name: string, schema: Schema | SchemaDefinition | (Schema | SchemaDefinition)[], options: TableOptionsOptional, ModelStore: (model: Model) => void) { | ||
super(); | ||
@@ -184,2 +192,3 @@ | ||
name, | ||
options, | ||
"getIndexes": async (): Promise<{GlobalSecondaryIndexes?: IndexItem[]; LocalSecondaryIndexes?: IndexItem[]; TableIndex?: any}> => { | ||
@@ -253,3 +262,6 @@ return (await Promise.all(this.getInternalProperties(internalProperties).schemas.map((schema) => schema.getIndexes(this)))).reduce((result, indexes) => { | ||
if (!table) { | ||
throw new CustomError.OtherError(`No table has been registered for ${this.name} model. Use \`new dynamoose.Table\` to register a table for this model.`); | ||
const modelObject = returnModel(this); | ||
const createdTable = new Table(Instance.default, this.getInternalProperties(internalProperties).name, [modelObject], this.getInternalProperties(internalProperties).options); | ||
this.getInternalProperties(internalProperties)._table = createdTable; | ||
return createdTable; | ||
} | ||
@@ -256,0 +268,0 @@ |
@@ -33,3 +33,7 @@ import {TableOptions, TableOptionsOptional} from "./index"; | ||
let customValue: TableOptionsOptional = {}; | ||
const customObject = { | ||
export interface TableOptionsAccessor { | ||
"set": (val: TableOptionsOptional) => void; | ||
"get": () => TableOptionsOptional; | ||
} | ||
const customObject: TableOptionsAccessor = { | ||
"set": (val: TableOptionsOptional): void => { | ||
@@ -36,0 +40,0 @@ customValue = val; |
@@ -114,3 +114,3 @@ import CustomError from "../Error"; | ||
*/ | ||
constructor (instance: Instance, name: string, models: Model[], options?: TableOptionsOptional) { | ||
constructor (instance: Instance, name: string, models: Model[], options: TableOptionsOptional = {}) { | ||
super(); | ||
@@ -117,0 +117,0 @@ |
@@ -10,2 +10,3 @@ import {Table, TableExpiresSettings, TableUpdateOptions, TableWaitForActiveSettings} from "."; | ||
import {TableClass} from "./types"; | ||
import * as defaults from "./defaults"; | ||
@@ -84,3 +85,4 @@ // Utility functions | ||
export async function createTable (table: Table, force = false): Promise<void | (() => Promise<void>)> { | ||
if (!force && ((await getTableDetails(table, {"allowError": true}) || {}).Table || {}).TableStatus === "ACTIVE") { | ||
const tableStatus = (await getTableDetails(table, {"allowError": true}))?.Table?.TableStatus; | ||
if (!force && tableStatus === "ACTIVE") { | ||
table.getInternalProperties(internalProperties).alreadyCreated = true; | ||
@@ -131,3 +133,5 @@ return (): Promise<void> => Promise.resolve.bind(Promise)(); | ||
async function check (count: number): Promise<void> { | ||
if (typeof table.getInternalProperties(internalProperties).options.waitForActive !== "boolean") { | ||
const waitForActiveSettingValue = table.getInternalProperties(internalProperties).options.waitForActive; | ||
if (typeof waitForActiveSettingValue !== "boolean" || waitForActiveSettingValue === true) { | ||
const waitForActiveSetting: TableWaitForActiveSettings = typeof waitForActiveSettingValue === "boolean" ? (defaults.original.waitForActive as TableWaitForActiveSettings) : waitForActiveSettingValue; | ||
try { | ||
@@ -144,5 +148,5 @@ // Normally we'd want to do `dynamodb.waitFor` here, but since it doesn't work with tables that are being updated we can't use it in this case | ||
if (count > 0) { | ||
(table.getInternalProperties(internalProperties).options.waitForActive as TableWaitForActiveSettings).check.frequency === 0 ? await utils.set_immediate_promise() : await utils.timeout((table.getInternalProperties(internalProperties).options.waitForActive as TableWaitForActiveSettings).check.frequency); | ||
waitForActiveSetting.check.frequency === 0 ? await utils.set_immediate_promise() : await utils.timeout(waitForActiveSetting.check.frequency); | ||
} | ||
if (Date.now() - start >= (table.getInternalProperties(internalProperties).options.waitForActive as TableWaitForActiveSettings).check.timeout) { | ||
if (Date.now() - start >= waitForActiveSetting.check.timeout) { | ||
return reject(new CustomError.WaitForActiveTimeout(`Wait for active timed out after ${Date.now() - start} milliseconds.`)); | ||
@@ -149,0 +153,0 @@ } else { |
@@ -6,7 +6,7 @@ interface ThroughputSettings { | ||
export interface ModelSettings { | ||
export interface TableSettings { | ||
throughput: ThroughputSettings | number | "ON_DEMAND"; | ||
} | ||
export default (options: Partial<ModelSettings>): {"BillingMode": "PAY_PER_REQUEST"} | {"ProvisionedThroughput": {"ReadCapacityUnits": number; "WriteCapacityUnits": number}} | {} => { | ||
export default (options: Partial<TableSettings>): {"BillingMode": "PAY_PER_REQUEST"} | {"ProvisionedThroughput": {"ReadCapacityUnits": number; "WriteCapacityUnits": number}} | {} => { | ||
if (!options.throughput) { | ||
@@ -13,0 +13,0 @@ return {}; |
{ | ||
"name": "dynamoose", | ||
"version": "3.0.0-beta.8", | ||
"version": "3.0.0-beta.9", | ||
"description": "Dynamoose is a modeling tool for Amazon's DynamoDB (inspired by Mongoose)", | ||
@@ -30,7 +30,7 @@ "homepage": "https://dynamoosejs.com", | ||
"@aws-sdk/util-dynamodb": "^3.142.0", | ||
"dynamoose-utils": "^3.0.0-beta.8", | ||
"dynamoose-utils": "^3.0.0-beta.9", | ||
"js-object-utilities": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"dynamoose-logger": "^3.0.0-beta.8" | ||
"dynamoose-logger": "^3.0.0-beta.9" | ||
}, | ||
@@ -48,3 +48,3 @@ "license": "Unlicense", | ||
], | ||
"gitHead": "d8455c3a245067a35ec829031db0da4e4f7562eb" | ||
"gitHead": "fa1592a15c445feeb8b5580bb0f4bed41d191a6e" | ||
} |
@@ -60,6 +60,13 @@ const dynamoose = require("../dist"); | ||
it("Should throw error if table hasn't been created", () => { | ||
it("Should not throw error if table hasn't been created", () => { | ||
const ddb = { | ||
"transactGetItems": () => { | ||
return Promise.resolve({}); | ||
} | ||
}; | ||
dynamoose.aws.ddb.set(ddb); | ||
dynamoose.model("User", {"id": Number, "name": String}); | ||
dynamoose.model("Credit", {"id": Number, "name": String}); | ||
return expect(callType.func(dynamoose.transaction)([{"Get": {"Key": {"id": {"N": "1"}}, "TableName": "User"}}, {"Get": {"Key": {"id": {"N": "2"}}, "TableName": "Credit"}}])).rejects.toEqual(new CustomError.InvalidParameter("No table has been registered for User model. Use `new dynamoose.Table` to register a table for this model.")); | ||
return expect(callType.func(dynamoose.transaction)([{"Get": {"Key": {"id": {"N": "1"}}, "TableName": "User"}}, {"Get": {"Key": {"id": {"N": "2"}}, "TableName": "Credit"}}])).resolves.toEqual(null); | ||
}); | ||
@@ -66,0 +73,0 @@ |
@@ -17,4 +17,3 @@ /* eslint @typescript-eslint/no-unused-vars: 0 */ | ||
// @ts-expect-error | ||
const shouldFailWithConfigurationParameter = dynamoose.model("User", {"id": String}, {}); | ||
const shouldNotFailWithConfigurationParameter = dynamoose.model("User", {"id": String}, {}); | ||
@@ -21,0 +20,0 @@ const model = dynamoose.model("User", {"id": Number}); |
/* eslint @typescript-eslint/no-unused-vars: 0 */ | ||
import * as dynamoose from "../../dist"; | ||
import {IndexType} from "../../dist/Schema"; | ||
@@ -118,1 +119,34 @@ // @ts-expect-error | ||
}); | ||
const shouldSucceedWithIndexTypeValueAsGlobalString = new dynamoose.Schema({ | ||
"id": { | ||
"type": String, | ||
"index": { | ||
"type": "global" | ||
} | ||
} | ||
}); | ||
const shouldSucceedWithIndexTypeValueAsLocalString = new dynamoose.Schema({ | ||
"id": { | ||
"type": String, | ||
"index": { | ||
"type": "local" | ||
} | ||
} | ||
}); | ||
const shouldSucceedWithIndexTypeValueAsGlobalEnumValue = new dynamoose.Schema({ | ||
"id": { | ||
"type": String, | ||
"index": { | ||
"type": IndexType.global | ||
} | ||
} | ||
}); | ||
const shouldSucceedWithIndexTypeValueAsLocalEnumValue = new dynamoose.Schema({ | ||
"id": { | ||
"type": String, | ||
"index": { | ||
"type": IndexType.local | ||
} | ||
} | ||
}); |
@@ -12,1 +12,7 @@ import * as dynamoose from "../../dist"; | ||
const shouldAllowForAccessingRangeKey = new dynamoose.Table("Table", []).rangeKey; | ||
const shouldAllowForAccessingTableDefaults = dynamoose.Table.defaults; | ||
const shouldAllowForGettingTableDefaults = dynamoose.Table.defaults.get(); | ||
const shouldAllowForSettingTableDefaults = dynamoose.Table.defaults.set({ | ||
"prefix": "MyApp_" | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
1345877
201
29795