类 Schema.CreateCollectionOptions

  • 封闭接口:
    Schema

    public static class Schema.CreateCollectionOptions
    extends Object
    Defines options to be passed to Schema.createCollection(String, CreateCollectionOptions).

    Allowed options are:

    • reuseExisting flag - similar to IF NOT EXISTS for CREATE TABLE
    • Schema.Validation object
    Examples:
     schema.createCollection(collName,
             new CreateCollectionOptions().setReuseExisting(false)
                     .setValidation(new Validation().setLevel(ValidationLevel.STRICT)
                             .setSchema("{\"id\": \"http://json-schema.org/idx\", \"$schema\": \"http://json-schema.org/draft-06/schema#\","
                                     + "\"type\": \"object\", \"properties\": {\"index\": {\"type\": \"number\"}},\"required\": [\"index\"]}")));
     
     schema.createCollection(collName, new CreateCollectionOptions().setReuseExisting(false).setValidation(new Validation().setLevel(ValidationLevel.OFF)));
     
     schema.createCollection(collName,
             new CreateCollectionOptions().setReuseExisting(true);