0

We have been developing collections in mongoDB, with

db.createCollection('xyzCollection', { 
  validator: 
{ 
  $jsonSchema: {....}}})

Now we are moving to AWS DocumentDB & this script fails with the error: enter image description here

Can someone help identifying the correct keyword to apply validator directly to schema, and not using backend code to do this.

I tried checking supported keywords on AWS documentations : https://docs.aws.amazon.com/documentdb/latest/developerguide/mongo-apis.html#mongo-apis-database I have also gone through with this link: Alternative to schema validation in AWS DocumentDB But the question is remains unsolved.

But 'validator' is not mentioned anywhere.

Does this mean that we cannot apply validations directly? Do we only have the option to apply validations via API.

1 Answer 1

1

AWS DocumentDB now supports schema validations and you can use validator keyword while creating collection.

Example:

db.createCollection('xyzCollection', {
   validator: {
     $jsonSchema: {
       required: ["name"]
     }
    }
  }
)
{ ok: 1 }

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.