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
As you can see in the schema, I have defined category in SubListingSchema as model and it is used in ListingsSchema. But when populating the listing, only the first element of the rooms array is populated by category and not the second one.
rohit-arium
changed the title
Populate: Currently populating only the first element of an array
[BUG] Populate: Currently populating only the first element of an array
Jul 23, 2023
Not sure if it is related but I was running into a similar issue because I didn't mention throughput while creating the Table, I changed it to the following to avoid it:
this._table=newTable('...',[this._model],{create: true,// Create if Table doesn't existupdate: true,// Update the metadata like tags, throughput etc when initializinginitialize: false,// Don't run initialization automatically but by calling .initialize()throughput: {// If set, this is the MAX boundary of the records that can be read/writeread: 150,// Dynamoose Default = 1write: 20,// Dynamoose Default = 1},});
You can choose the throughput as Pay as you go but you would need to see how it fits in your pricing.
Summary:
As you can see in the schema, I have defined category in SubListingSchema as model and it is used in ListingsSchema. But when populating the listing, only the first element of the rooms array is populated by category and not the second one.
Code sample:
Schema
Current output and behavior (including stack trace):
"rooms": [
{
"name": "Living Room",
"image": "image_link",
"id": "292f16d6-c9d3-46f9-aec5-5d9ebced0cc7",
"category": {
"name": "Kitchen",
"createdAt": "2023-07-11T09:57:00.597Z",
"id": "6b5909d1-145f-4366-ad35-6ab857feab16",
"updatedAt": "2023-07-11T09:57:00.597Z"
},
"dimensions": "25'' h x 84.5'' w x 29.5'' d - Meters",
"props": []
},
{
"name": "Kitchen",
"image": "image_link",
"id": "2a0b06bd-90d8-47c3-868d-704101b5fbdd",
"category": "6b5909d1-145f-4366-ad35-6ab857feab16",
"dimensions": "25'' h x 84.5'' w x 29.5'' d - Meters",
"props": []
}
]
Expected output and behavior:
"rooms": [
{
"name": "Living Room",
"image": "image_link",
"id": "292f16d6-c9d3-46f9-aec5-5d9ebced0cc7",
"category": {
"name": "Kitchen",
"createdAt": "2023-07-11T09:57:00.597Z",
"id": "6b5909d1-145f-4366-ad35-6ab857feab16",
"updatedAt": "2023-07-11T09:57:00.597Z"
},
"dimensions": "25'' h x 84.5'' w x 29.5'' d - Meters",
"props": []
},
{
"name": "Kitchen",
"image": "image_link",
"id": "2a0b06bd-90d8-47c3-868d-704101b5fbdd",
"category": {
"name": "Kitchen",
"createdAt": "2023-07-11T09:57:00.597Z",
"id": "6b5909d1-145f-4366-ad35-6ab857feab16",
"updatedAt": "2023-07-11T09:57:00.597Z"
},,
"dimensions": "25'' h x 84.5'' w x 29.5'' d - Meters",
"props": []
}
]
Environment:
Operating System: windows
Operating System Version: 11
Node.js version (
node -v
): 18.15,0NPM version: (
npm -v
): 9.5.0Dynamoose version: 3.2.0
Other information (if applicable):
Other:
The text was updated successfully, but these errors were encountered: