question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] When updating (Model.update), content of a property of type Object is empty in the result

See original GitHub issue

Summary:

When updating (Model.update), content of a property of type Object is empty in the returned object. The object (and the properties of type object) are correctly saved in dynamoose. Only the returned object is not complete.

Code sample:

Schema

export const schema = new dynamoose.Schema({
    id: {
        type: String,
        rangeKey: true
    },
    owner: {
        type: String,
        hashKey: true
    },
    title: {
        type: String
    },
    data: {
        type: Object
    }
}, { saveUnknown: ['data.**'] });

Model

dynamoose.model('alerts', schema);

General

const alert = await Alert.update(
            {
                id: "5aab1049-42e8-46b9-9e8e-55b4fb8acc39",
                owner: "32f96e39-0a9e-48dc-8696-23235e43ed15"
            },
            {
                title: "Test updated",
                data: {
                        "a": "A updated",
                        "b": "B updated"
                }
            });

console.log(alert);

Current output and behavior (including stack trace):

{
    "owner": "32f96e39-0a9e-48dc-8696-23235e43ed15",
    "id": "5aab1049-42e8-46b9-9e8e-55b4fb8acc39",
    "data": {},
    "title": "Test updated"
}

Expected output and behavior:

{
    "owner": "32f96e39-0a9e-48dc-8696-23235e43ed15",
    "id": "5aab1049-42e8-46b9-9e8e-55b4fb8acc39",
    "data": {
        "a": "A updated",
        "b": "B updated"
    }
    "title": "Test updated"
}

Environment:

Operating System: Mac Operating System Version: Big Sur 11.2.3 Node.js version (node -v): v14.16.0 NPM version: (npm -v): 6.14.12 Dynamoose version: 2.7.3

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
ericreiscommented, Apr 18, 2021

I am having the same issue as described above. The data is correctly stored in Dynamo and when calling the get method it works just fine.

3reactions
epiphaneSpectercommented, Apr 19, 2021

I am having the same issue if i update an array properties

Read more comments on GitHub >

github_iconTop Results From Across the Web

If value of a property is null when updating then that ...
In mongodb you cannot unset a field in a document by just assigning undefined to it. You should use the $unset operator. So...
Read more >
Tutorial: Update related data with EF in an ASP.NET MVC ...
In this tutorial you'll update related data. For most relationships, this can be done by updating either foreign key fields or navigation ...
Read more >
Review and troubleshoot import errors - Knowledge Base
Once you've updated the value, then re-import the file. You can also manually update the property value in the affected records.
Read more >
db.collection.update() — MongoDB Manual
Since a missing key value is returned as part of a null equality match, to avoid updating a null-valued key, include additional query...
Read more >
Set Data Properties - MATLAB & Simulink
Properties vary according to the scope and type of the data object. ... maintenance of your model because you can update multiple properties...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found