Example #1
0
export function getCollection(collectionName: string): Collection<any, any> {
  const engine = getEngine();
  const collection = engine.createCollection(collectionName);

  if (collection === null) {
    throw new SilentError(`Invalid collection (${collectionName}).`);
  }
  return collection;
}
Example #2
0
export function getCollection(collectionName: string): Collection<any, any> {
  const engine = getEngine();
  const collection = engine.createCollection(collectionName);

  if (collection === null) {
    throw new UnknownCollectionError(collectionName);
  }

  return collection;
}
Example #3
0
export function getCollection(collectionName: string): Collection<any, any> {
  const engineHost = getEngineHost();
  const engine = getEngine();

  // Add support for schemaJson.
  engineHost.registerOptionsTransform((schematic: FileSystemSchematicDesc, options: any) => {
    if (schematic.schema) {
      const SchemaMetaClass = SchemaClassFactory<any>(schematic.schemaJson!);
      const schemaClass = new SchemaMetaClass(options);
      return schemaClass.$$root();
    }
    return options;
  });

  const collection = engine.createCollection(collectionName);

  if (collection === null) {
    throw new SilentError(`Invalid collection (${collectionName}).`);
  }
  return collection;
}