Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conditional write with multiple constraints #195

Open
simoami opened this issue Nov 19, 2016 · 0 comments
Open

conditional write with multiple constraints #195

simoami opened this issue Nov 19, 2016 · 0 comments

Comments

@simoami
Copy link

simoami commented Nov 19, 2016

Hello,
I'd like to know if it's possible to use the overwrite flag with constraints on the hash key and 2 index attributes.

consider my model:

var UserModel = db.instance.define('user', {
  hashKey: 'id',
  schema: {
    id: db.instance.types.uuid(),
    cognitoId: Joi.string(),
    email: Joi.string()
  },
  indexes: [
    { hashKey: 'email', type: 'global', name: 'emailIndex' },
    { hashKey: 'cognitoId', type: 'global', name: 'cognitoIdIndex' }
  ],
  tableName: 'users'
});

Would User.create(user, {overwrite : false}, cb) be enough to prevent duplicate id, cognitoId and email? or do I need to explicitly construct an array of conditional expressions to cover all 3? Do perhaps I could redefine the model in a way that overwrite works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant