mongoose#MongooseDocument TypeScript Examples

The following examples show how to use mongoose#MongooseDocument. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: schema-type.spec.ts    From pebula-node with MIT License 6 votes vote down vote up
describe('goosetyped', () => {
  describe('decorators', () => {

    it('should register a schema type definitions using GtSchemaType', () => {
      const metadata = {
        schemaType: Schema.Types.Array,
        isContainer: true,
        toSchema(reflectedType: typeof SchemaType | Schema, userType?: typeof SchemaType | Schema) {
          const arraySchemaTypeOpts: SchemaTypeOpts<any> = {
           type: [userType],
          };
          return arraySchemaTypeOpts;
        },
      };

      @GtSchemaType(metadata)
      class DocumentArray<T extends MongooseDocument> extends Types.DocumentArray<T> {}

      expect(getSchemaType(DocumentArray)).toBe(metadata);
    });

  });
});