mongoose#SchemaTypeOpts TypeScript Examples
The following examples show how to use
mongoose#SchemaTypeOpts.
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: built-in.ts From pebula-node with MIT License | 6 votes |
@GtSchemaType({
schemaType: Schema.Types.Array,
isContainer: true,
toSchema(reflectedType: typeof SchemaType | Schema, userType?: typeof SchemaType | Schema) {
const arraySchemaTypeOpts: SchemaTypeOpts<any> = {
type: [userType],
};
return arraySchemaTypeOpts;
},
})
export class DocumentArray<T extends MongooseDocument> extends Types.DocumentArray<T> {
}
Example #2
Source File: schema-type.spec.ts From pebula-node with MIT License | 6 votes |
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);
});
});
});
Example #3
Source File: schema-type-map.ts From pebula-node with MIT License | 6 votes |
ArrayTypeMetadata: GtSchemaTypeMetadataArgs = {
schemaType: Schema.Types.Array,
isContainer: true,
toSchema(reflectedType: typeof SchemaType | Schema, userType?: typeof SchemaType | Schema) {
const arraySchemaTypeOpts: SchemaTypeOpts<any> = {
type: [userType],
};
return arraySchemaTypeOpts;
},
}
Example #4
Source File: schema-type-map.ts From pebula-node with MIT License | 6 votes |
MapTypeMetadata: GtSchemaTypeMetadataArgs = {
schemaType: Schema.Types.Map,
isContainer: true,
toSchema(reflectedType: typeof SchemaType | Schema, userType?: typeof SchemaType | Schema) {
const mapSchemaTypeOpts: SchemaTypeOpts<any> = {
type: reflectedType,
of: userType,
};
return mapSchemaTypeOpts;
},
}
Example #5
Source File: mongo-type-resolver.ts From pebula-node with MIT License | 6 votes |
export function createFinalColumnTypes(reflectedType: ResolveType, userType: Partial<ResolveType> | undefined, options: GtColumnMetadataArgs<any>) {
const schema = getMongoType(reflectedType, userType);
const schemaTypeOpts: SchemaTypeOpts<any> = schema instanceof Schema || isFunction(schema)
? { type: schema }
: schema
;
const underlyingType = (userType && userType.tsType) || reflectedType.tsType;
for (const k of PASS_THROUGH_COLUMN_OPTIONS) {
if (k in options) {
schemaTypeOpts[k] = options[k];
}
}
if (options.enum) {
schemaTypeOpts.enum = Array.isArray(options.enum)
? options.enum
: resolveEnum(options.enum, underlyingType)
;
}
return { underlyingType, schema: schemaTypeOpts };
}
Example #6
Source File: document-array-path.ts From pebula-node with MIT License | 5 votes |
constructor(container: GtSchemaContainer, key: string, schema: Schema, typeOpts: SchemaTypeOpts<any>) {
super(key, schema, typeOpts);
this[SCHEMA_CONTAINER] = container;
this.caster = this.casterConstructor;
}
Example #7
Source File: schema-explorer.ts From pebula-node with MIT License | 5 votes |
schema(schema: SchemaTypeOpts<any>): this {
const { resolvedColumnType } = this.column;
expect(resolvedColumnType.schema).toEqual(schema);
return this;
}
Example #8
Source File: schema-explorer.ts From pebula-node with MIT License | 5 votes |
hasOptionValue<TOptKey extends keyof SchemaTypeOpts<any>>(key: TOptKey, value: SchemaTypeOpts<any>[TOptKey]): this {
expect(this.schemaType['options'][key]).toEqual(value);
return this;
}