clarkie / dynogels

DynamoDB data mapper for node.js. Originally forked from https://github.com/ryanfitz/vogels
Other
490 stars 110 forks source link

Dynamic Key Object #68

Closed marckaraujo closed 7 years ago

marckaraujo commented 7 years ago

I am trying to create this object:

Lol = _dynogels2.default.define('Lol', {
                hashKey: 'userId',
                timestamps: true,
                tableName: 'Lol',
                schema: _joi2.default.object({
                    id: _dynogels2.default.types.uuid(),
                    isVerified: _joi2.default.boolean(),
                    messages: _joi2.default.object({
                        arg: _joi2.default.string(),
                        value: _joi2.default.boolean()
                    })
                }).unknown(true).options({ stripUnknown: true })
            });

My json:

{
    "id": "223da927-4547-47a4-9675-1a2934dbde9d",
    "isVerified": true,
    "messages": {
      "30_level": true
    }
  }

But the messages save in Dynamodb is:

{
    "id": "223da927-4547-47a4-9675-1a2934dbde9d",
    "isVerified": true,
    "messages": {}
  }
clarkie commented 7 years ago

Hi, that's some funky looking Joi setup you've got going on there. Has that been transpiled? It might be better if you post the original too.

My guess is that you're 30_level key is being stripped because you have the stripUnknown flag set to true.