db.createCollection('User', {
  validator: {
    $jsonSchema: {
      bsonType: 'object',
      title: 'User',
      required: ['username', 'email', 'password', 'role'],
      properties: {
        username: {
          bsonType: 'string'
        },
        email: {
          bsonType: 'string'
        },
        password: {
          bsonType: 'string'
        },
        role: {
          bsonType: 'string'
        }
      }
    }
  },
  autoIndexId: true
});
db.createCollection('Project', {
  validator: {
    $jsonSchema: {
      bsonType: 'object',
      title: 'Project',
      required: ['name', 'created_at', 'ownerId'],
      properties: {
        name: {
          bsonType: 'string'
        },
        created_at: {
          bsonType: 'date'
        },
        ownerId: {
          bsonType: 'objectId'
        }
      }
    }
  }
});
db.createCollection('UserProject', {
  validator: {
    $jsonSchema: {
      bsonType: 'object',
      title: 'UserProject',
      required: ['projectId', 'userId', 'user_role'],
      properties: {
        projectId: {
          bsonType: 'objectId'
        },
        userId: {
          bsonType: 'objectId'
        },
        user_role: {
          bsonType: 'string'
        }
      }
    }
  }
});
db.createCollection('UserDataset', {
  validator: {
    $jsonSchema: {
      bsonType: 'object',
      title: 'UserDataset',
      required: ['userId', 'datasetId', 'user_role'],
      properties: {
        userId: {
          bsonType: 'objectId'
        },
        datasetId: {
          bsonType: 'objectId'
        },
        user_role: {
          bsonType: 'string'
        }
      }
    }
  }
});
db.createCollection('Image', {
  validator: {
    $jsonSchema: {
      bsonType: 'object',
      title: 'Image',
      required: ['name', 'datasetId'],
      properties: {
        name: {
          bsonType: 'string'
        },
        format: {
          bsonType: 'string'
        },
        categories: {
          bsonType: 'array',
          items: {
            bsonType: 'string'
          }
        },
        datasetId: {
          bsonType: 'objectId'
        }
      }
    }
  }
});
db.createCollection('ImageObject', {
  validator: {
    $jsonSchema: {
      bsonType: 'object',
      title: 'ImageObject',
      required: ['imageId'],
      properties: {
        name: {
          bsonType: 'string'
        },
        imageId: {
          bsonType: 'objectId'
        }
      }
    }
  }
});
db.createCollection('ObjectPoint', {
  validator: {
    $jsonSchema: {
      bsonType: 'object',
      title: 'ObjectPoint',
      properties: {
        x: {
          bsonType: 'string'
        },
        y: {
          bsonType: 'string'
        }
      }
    }
  }
});
db.createCollection('Dataset', {
  validator: {
    $jsonSchema: {
      bsonType: 'object',
      title: 'Dataset',
      required: ['name', 'projectId', 'ownerId'],
      properties: {
        name: {
          bsonType: 'string'
        },
        projectId: {
          bsonType: 'objectId'
        },
        ownerId: {
          bsonType: 'objectId'
        }
      }
    }
  }
});