Comments (4)
define property with @Property({ type: t.datetime }) or @Property({ type: DateTimeType }) (recommended in docs)
Where do you read it's "recommended"? I would actually discourage it, since it means the hydration will use the custom type convertor methods, resulting in a (small) perf hit. I would love to find a way around this, but some types need the convertors (and users can extend the type, in which case we also need to respect it).
edit: just to be clear, I would love to find a way around the perf issue, what you are reporting here is something we will surely find a fix for regardless of that
from mikro-orm.
By "recommended" I mean that I understood that types may be defined by t.
constants:
There is also a types map (exported also as just t for brevity):
import { t } from '@mikro-orm/core'; // `t` or `types` @Property({ type: t.text }) bio = '';
So that's why I'm using t.datetime
for date and time type.
If you discourage it, what is the proper way of defining it?
Other ways ('datetime'|'Date'|Date
) work fine, but I haven't seen these in docs, except Upgrading from v5 to v6 > Changes in Date property mapping
from mikro-orm.
Other ways ('datetime'|'Date'|Date) work fine
Any of those. When you use the types map, you use the custom type, which in fact does nothing (but the hydration functions still need to call its convertor methods, as it does not know they are in fact just identity functions).
If you are not using a union type (as in Date | null
), you don't need anything, as the type will be inferred via reflect metadata. Equivalent to that is adding type: 'Date'
, but all the other variants should converge to the same - the problematic part is only when you use the type implementation.
Again, this is rather something to improve than to document, I don't want people to think about this.
from mikro-orm.
Thank you!
from mikro-orm.
Related Issues (20)
- QueryBuilder `execute` Method Doesn't Properly Map Embeddables HOT 7
- Composite primary keys in relations populates foreign keys with incorrect values HOT 4
- deprecated subdependencies
- array out of bounds error with columns shared in composite PK and FK HOT 1
- createForeignKeyConstraints Configuration options support in Migrations HOT 1
- Subsequent queries from identity cache don't honor field settings or exclude options HOT 1
- Not able to run migrations in MS SQL Server HOT 6
- docs: incorrect example code, bug: entity discovery
- MS SQL Get Database Existence query fails during application start HOT 2
- Mikro orm property initalizers not working when using minifed builds
- Nested Embeddables Prefix Not Respected
- Mysql 5.7 on Google Cloud (SQL) throws error using nestjs
- [v6] Batch Update on unique field failed HOT 4
- Cannot update entity with generated column
- EntitySchema custom entity classes do not work if class is defined in seperate file
- Support partial indexes in onConflict clauses
- Wrong migration schema generated when adding value to Enum HOT 6
- nativeDelete is not supplying table alias in all instances HOT 2
- (Multi-instances, PostgreSqlDriver) Transaction query already complete, run with DEBUG=knex:tx for more info
- Wrong migration schema generated when use EntityCaseNamingStrategy HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mikro-orm.