ryanfitz / vogels

DynamoDB data mapper for node.js
Other
698 stars 125 forks source link

Schemaless feature #146

Open daaru00 opened 8 years ago

daaru00 commented 8 years ago

Hi, can I declare a schemaless model? If I try to add an attribute that is not in the schema I get an error: [ValidationError: test1 is not allowed. password test2 not allowed]

I doing something wrong?

awerlang commented 8 years ago
var Account = vogels.define('Account', {
  hashKey : 'email',

  // add the timestamp attributes (updatedAt, createdAt)
  timestamps : true,

  schema : Joi.object({
    email   : Joi.string().email(),
    name    : Joi.string(),
    age     : Joi.number(),
    roles   : vogels.types.stringSet(),
    settings : {
      nickname      : Joi.string(),
      acceptedTerms : Joi.boolean().default(false)
    }
  }).unknown(true);
});

Or even just Joi.any() or Joi.object()