You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Dynamoose V2 it was possible to created nested schema relations by using
MySchema.schemaObject
In V3 this attribute is no longer available and I found no way to getting the SchemaDefinition from a Schema object.
Code sample:
Schema
exportconstCompanySchema=newdynamoose.Schema({name: {required: true,type: String,}});exportconstUserSchema=newdynamoose.Schema({name: {required: true,type: String,},company: {type: Object,schema: CompanySchema.schemaObject,// not available anymore and just using the Schema doesnt work},});
Current output and behavior (including stack trace):
Error trying to update: TypeError: Cannot read properties of undefined (reading 'schema')
at ...\node_modules\dynamoose\dist\Schema.js:967:50
at Array.reduce (<anonymous>)
Expected output and behavior:
Nested schema definition loaded
Environment:
Operating System: Windows
Operating System Version: 11 Pro
Node.js version (node -v): 18
NPM version: (npm -v): v18.16.0
Dynamoose version: 3.2.0
Other information (if applicable):
Other:
I have read through the Dynamoose documentation before posting this issue
I have searched through the GitHub issues (including closed issues) and pull requests to ensure this issue has not already been raised before
I have searched the internet and Stack Overflow to ensure this issue hasn't been raised or answered before
I have tested the code provided and am confident it doesn't work as intended
I have filled out all fields above
I am running the latest version of Dynamoose
The text was updated successfully, but these errors were encountered:
You mention and just using the Schema doesnt work, but you don't give any detail about why that doesn't work. Can you provide me with more detail here? Is there an error that gets thrown? How doesn't it work?
exportconstUserSchema=newdynamoose.Schema({name: {required: true,type: String,},company: {type: Object,schema: CompanySchema,// results in error},});
results in the following error message
Error trying to update: TypeError: Cannot read properties of undefined (reading 'schema')
at ...\node_modules\dynamoose\dist\Schema.js:967:50
at Array.reduce (<anonymous>)
It looks like you are just trying to reference another Model. If that is the case based on this documentation for the Model type, you should be able to do this
Summary:
In Dynamoose V2 it was possible to created nested schema relations by using
In V3 this attribute is no longer available and I found no way to getting the SchemaDefinition from a Schema object.
Code sample:
Schema
Model
General
Current output and behavior (including stack trace):
Expected output and behavior:
Nested schema definition loaded
Environment:
Operating System: Windows
Operating System Version: 11 Pro
Node.js version (
node -v
): 18NPM version: (
npm -v
): v18.16.0Dynamoose version: 3.2.0
Other information (if applicable):
Other:
The text was updated successfully, but these errors were encountered: