artmapper
Version:
Spring Boot clone for Node.js with TypeScript/JavaScript - JPA-like ORM, Lombok decorators, dependency injection, and MySQL support
50 lines • 2.33 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
// JavaScript example - Spring Boot TS Entity
const { Entity, Table, Column, Id, GeneratedValue, Data, OneToMany } = require('../../index');
let User = class User {
};
__decorate([
Id(),
GeneratedValue({ strategy: 'AUTO' }),
Column({ name: 'id', type: 'INT', nullable: false }),
__metadata("design:type", Object)
], User.prototype, "id", void 0);
__decorate([
Column({ name: 'username', type: 'VARCHAR', length: 100, nullable: false, unique: true }),
__metadata("design:type", Object)
], User.prototype, "username", void 0);
__decorate([
Column({ name: 'email', type: 'VARCHAR', length: 255, nullable: false, unique: true }),
__metadata("design:type", Object)
], User.prototype, "email", void 0);
__decorate([
Column({ name: 'password', type: 'VARCHAR', length: 255, nullable: false }),
__metadata("design:type", Object)
], User.prototype, "password", void 0);
__decorate([
OneToMany(() => require('./Post').Post, { mappedBy: 'userId' }),
__metadata("design:type", Object)
], User.prototype, "posts", void 0);
__decorate([
Column({ name: 'created_at', type: 'TIMESTAMP', nullable: true, default: 'CURRENT_TIMESTAMP' }),
__metadata("design:type", Object)
], User.prototype, "createdAt", void 0);
__decorate([
Column({ name: 'updated_at', type: 'TIMESTAMP', nullable: true, default: 'CURRENT_TIMESTAMP' }),
__metadata("design:type", Object)
], User.prototype, "updatedAt", void 0);
User = __decorate([
Entity('User'),
Table('users'),
Data()
], User);
module.exports = { User };
//# sourceMappingURL=User.js.map