diff --git a/lib/storages/type-metadata.storage.ts b/lib/storages/type-metadata.storage.ts index 22979a5f..25073689 100644 --- a/lib/storages/type-metadata.storage.ts +++ b/lib/storages/type-metadata.storage.ts @@ -8,7 +8,7 @@ export class TypeMetadataStorageHost { private properties = new Array(); addPropertyMetadata(metadata: PropertyMetadata) { - this.properties.push(metadata); + this.properties.unshift(metadata); } addSchemaMetadata(metadata: SchemaMetadata) { diff --git a/tests/e2e/schema-definitions.factory.spec.ts b/tests/e2e/schema-definitions.factory.spec.ts index a3d06f45..347e6d37 100644 --- a/tests/e2e/schema-definitions.factory.spec.ts +++ b/tests/e2e/schema-definitions.factory.spec.ts @@ -84,6 +84,26 @@ class ExampleClass { describe('DefinitionsFactory', () => { it('should generate a valid schema definition', () => { const definition = DefinitionsFactory.createForClass(ExampleClass); + + expect(Object.keys(definition)).toEqual([ + 'objectId', + 'name', + 'buffer', + 'decimal', + 'mixed', + 'expiresAt', + 'map', + 'isEnabled', + 'number', + 'ref', + 'child', + 'child2', + 'nodes', + 'customArray', + 'customObject', + 'any', + 'array', + ]); expect(definition).toEqual({ objectId: { type: mongoose.Schema.Types.ObjectId,