Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { RelayedQuery } from 'auto-relay'
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from 'typeorm'
import { Resolver, ObjectType, Field, ID, Query } from "type-graphql"
import { Sortable } from '@auto-relay/sorting'
import { OrderOptions, TypeORMOrdering } from '@auto-relay/typeorm'
@Entity()
@ObjectType()
export class SortableEntity extends BaseEntity {
@PrimaryGeneratedColumn('uuid')
@Field(() => ID)
public id!: string
@Field()
@Column({ default: () => "RANDOM()"})
public sortingFoo!: number
@Field()
@Column({ default: () => "RANDOM()"})
public sortingBar!: number
@Field(() => Number)
public get sortingComputed(): number {
return this.sortingFoo / this.sortingBar
}
import { Column, createConnection, Entity, PrimaryGeneratedColumn} from "typeorm";
@Entity()
export class FooModel {
@PrimaryGeneratedColumn("uuid")
public id: string;
@Column()
public bar: string;
}
before(async () => {
await createConnection({
type: "postgres",
host: "localhost",
port: 5432,
username: "postgres",
password: "",
database: "test_db",
entities: [ FooModel ],
synchronize: true,
PrimaryGeneratedColumn,
Column,
Index,
UpdateDateColumn,
CreateDateColumn,
OneToOne,
JoinColumn,
ManyToOne
} from 'typeorm';
import User from './User';
@Entity('auth_tokens', {
synchronize: true
})
export default class AuthToken {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column('uuid')
fk_user_id!: string;
@Column('timestampz')
@CreateDateColumn()
created_at!: Date;
@Column('timestamptz')
@UpdateDateColumn()
updated_at!: Date;
@Column({ default: false })
disabled!: boolean;
@Column()
@Index()
command!: string;
@Column()
enabled!: boolean;
@Column()
visible!: boolean;
@OneToMany(() => CommandsResponses, (response) => response.command, {
cascade: true,
})
responses!: CommandsResponses[];
};
@Entity()
export class CommandsResponses {
@PrimaryGeneratedColumn('uuid')
id!: string;
@ManyToOne(() => Commands, (command) => command.responses, {
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
})
command!: Commands;
@Column()
order!: number;
@Column('text')
response!: string;
@Column()
stopIfExecuted!: boolean;
@Column()
permission!: string;
@Column()
filter!: string;
Column,
CreateDateColumn,
BeforeInsert,
OneToMany,
ManyToMany,
JoinTable,
} from 'typeorm';
import * as bcrypt from 'bcryptjs';
import * as jwt from 'jsonwebtoken';
import { IdeaEntity } from '../idea/idea.entity';
import { UserRO } from './user.dto';
@Entity('user')
export class UserEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@CreateDateColumn()
created: Date;
@Column({
type: 'text',
unique: true,
})
username: string;
@Column('text')
password: string;
@OneToMany(type => IdeaEntity, idea => idea.author, { cascade: true })
ideas: IdeaEntity[];
/*
Copyright (C) 2019 - ScuroGuardiano
This file is part of Dark Nova project.
This file and project is licensed under the MIT license
See file LICENSE in the root of this project or go to for full license details.
*/
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from 'typeorm';
@Entity()
export default class PlanetBuildings extends BaseEntity {
[Key: string]: any;
@PrimaryGeneratedColumn('increment')
public id: number;
@Column('smallint', { default: 0, nullable: false })
public metalMine = 0;
@Column('smallint', { default: 0, nullable: false })
public crystalMine = 0;
@Column('smallint', { default: 0, nullable: false })
public deuteriumSynthesizer = 0;
@Column('smallint', { default: 0, nullable: false })
public solarPlant = 0;
@Column('smallint', { default: 0, nullable: false })
public fusionReactor = 0;
public get crystalPerHour(): number {
return this.economyData.production.crystal;
}
public get deuteriumPerHour(): number {
return this.economyData.production.deuter;
}
public get metalStorage(): number {
return 5000 * Math.floor(2.5 * Math.exp(20 * this.buildings.metalStorage / 33));
}
public get crystalStorage(): number {
return 5000 * Math.floor(2.5 * Math.exp(20 * this.buildings.crystalStorage / 33));
}
public get deuteriumStorage(): number {
return 5000 * Math.floor(2.5 * Math.exp(20 * this.buildings.deuteriumStorage / 33));
}
@PrimaryGeneratedColumn('increment')
public id: number;
@CreateDateColumn()
public createdAt: Date;
@UpdateDateColumn()
public updatedAt: Date;
//Last update from Updater
@Column()
public lastUpdate: Date;
@Column()
public name: string;
@Column({ nullable: false })
* limitations under the License.
*/
import { Column, Entity, CreateDateColumn, PrimaryGeneratedColumn, BaseEntity, getConnection } from 'typeorm';
import EthCrypto from 'eth-crypto';
import { Logger } from '../Logger';
import { EncryptorContainer } from './encryption/EncryptorContainer';
import { Network } from './Contract';
const EthereumTx = require('ethereumjs-tx');
const logger = Logger.get(module.filename);
@Entity()
export class Wallet extends BaseEntity {
@PrimaryGeneratedColumn('uuid') id: string;
@CreateDateColumn() createdDate: Date;
@Column({ nullable: true }) title: string;
@Column('text') public_key: string;
@Column('text') address: string;
@Column('text') private_key: string;
private unlocked_private_key: string;
static async getById(id: string) {
const DB = getConnection();
const repository = DB.getRepository(Wallet);
let wallet = await repository.findOne({ id: id });
if (!wallet) {
throw new Error('Wallet not found');
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, OneToOne, JoinColumn, OneToMany, ManyToMany } from 'typeorm';
import { EmailAndPasswordProvider } from './providers/email-and-password/email-and-password-provider.entity';
import { GoogleProvider } from './providers/google/google-provider.entity';
import { FacebookProvider } from './providers/facebook/facebook-provider.entity';
import { Message } from '../chat/message.entity';
import { Chatroom } from '../chat/chatroom.entity';
@Entity()
export class User {
@PrimaryGeneratedColumn('uuid') id: string;
@CreateDateColumn() createdDate: Date;
@Column() isAnonymous: boolean;
@Column('simple-array') roles: string[];
@Column({ nullable: true })
emailAndPasswordProviderId: number;
@OneToOne(type => EmailAndPasswordProvider, { cascade: true })
@JoinColumn()
emailAndPasswordProvider: EmailAndPasswordProvider;
@Column({ nullable: true })
googleProviderId: number;
loudness!: number;
@Column()
length!: number;
@Column({ default: false })
forceVolume!: boolean;
@Column()
volume!: number;
@Column()
startTime!: number;
@Column()
endTime!: number;
};
@Entity()
export class SongRequest {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column()
videoId!: string;
@Column('bigint', { transformer: new ColumnNumericTransformer(), default: 0 })
addedAt!: number;
@Column()
title!: string;
@Column('float')
loudness!: number;
@Column()
length!: number;
@Column()
username!: string;
};
@Entity()