arangojs icon indicating copy to clipboard operation
arangojs copied to clipboard

Incorrect property name in "CreateCollectionOptions" for ArangoDB 3.7

Open tombarton opened this issue 6 years ago • 1 comments

Version: 7.0.0-rc.1

I'm not 100% sure if arangojs supports the upcoming release of ArangoDB 3.7, so please feel free to close this if so.

I was testing creating a collection programatically as described in the documentation:

const collection = database.collection(col.name);
const collectionExists = await collection.exists();

if (!collectionExists) {
  await collection.create({
    validation: {
      rule: {
        properties: { nums: { type: "array", items: { type: "number", maximum: 6 } } },
        additionalProperties: { type: "string" },
        required: ["nums"],
      },
    },
  });
}

The create method executes successfully, however, when inspecting the collection via the web interface or retrieving the properties of it via the REST API, the schema is not present. This is due to the fact that the options for the create method are spread into the POST request for /_api/collection (https://github.com/arangodb/arangojs/blob/main/src/collection.ts#L3163), but the Swagger documentation lists the property name as schema rather than validation.

Screenshot 2020-07-29 at 21 49 16

I've updated this and tested it locally, and it resolves the issue. I'm happy to raise a PR but I wanted to ensure that the library is supporting ArangoDB 3.7.

tombarton avatar Jul 29 '20 20:07 tombarton

Looks like I was working off an earlier development version and the property may have been renamed.

pluma avatar Aug 03 '20 09:08 pluma