typeorm#BeforeInsert TypeScript Examples

The following examples show how to use typeorm#BeforeInsert. 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: DispatchedEntity.ts    From context-mod with MIT License 6 votes vote down vote up
@BeforeInsert()
    setPrimitives() {
        if (this.cancelIfQueued !== undefined) {
            if (typeof this.cancelIfQueued === 'boolean') {
                // @ts-ignore
                this.cancelIfQueued = this.cancelIfQueued ? 'true' : 'false';
            } else if (Array.isArray(this.cancelIfQueued)) {
                // @ts-ignore
                this.cancelIfQueued = JSON.stringify(this.cancelIfQueued);
            }
        }
    }
Example #2
Source File: NoSqlBase.ts    From confidential-storage with Apache License 2.0 6 votes vote down vote up
@BeforeInsert()
  public async validate() {
    // TODO: here we could assign IDs by content

    // docs and indexes have id set by client.
    if (!this._id && !this.id) {
      this._id = await EdvClient.generateId();
    } else {
      // special ids for docs
      this._id = this.id;
    }
  }
Example #3
Source File: vulnerability.ts    From crossfeed with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@BeforeInsert()
  @BeforeUpdate()
  setSeverity() {
    if (!this.cvss) return;
    if (this.cvss === 0) this.severity = 'None';
    else if (this.cvss < 4) this.severity = 'Low';
    else if (this.cvss < 7) this.severity = 'Medium';
    else if (this.cvss < 9) this.severity = 'High';
    else this.severity = 'Critical';
  }
Example #4
Source File: User.ts    From jaebook-server with MIT License 6 votes vote down vote up
@BeforeInsert()
  async hashPassword() {
    this.password = await bcrypt.hash(this.password, 10);
  }
Example #5
Source File: stockStatus.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #6
Source File: Contact.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #7
Source File: Customer.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #8
Source File: CustomerWishlist.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #9
Source File: EmailTemplate.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #10
Source File: LoginLog.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async hashPassword(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #11
Source File: ManufacturerModel.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #12
Source File: Order.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #13
Source File: OrderLog.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #14
Source File: OrderProduct.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #15
Source File: OrderStatus.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #16
Source File: OrderTotal.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #17
Source File: RandomIdBaseEntity.ts    From context-mod with MIT License 5 votes vote down vote up
@BeforeInsert()
    setId() {
        if(this.id === undefined) {
            this.id = nanoid(16);
        }
    }
Example #18
Source File: Page.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #19
Source File: ProductImage.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #20
Source File: ProductModel.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #21
Source File: ProductToCategory.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #22
Source File: Setting.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #23
Source File: User.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async hashPassword(): Promise<void> {
        // this.password = await User.hashPassword(this.password);
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #24
Source File: UserGroup.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #25
Source File: Zone.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #26
Source File: productViewLog.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeInsert()
    public async createDetails(): Promise<void> {
        this.createdDate = moment().format('YYYY-MM-DD HH:mm:ss');
    }
Example #27
Source File: KnowledgeSkill.ts    From liferay-grow with MIT License 5 votes vote down vote up
@BeforeInsert()
  addSlug(): void {
    this.slug = slugify(this.name);
  }
Example #28
Source File: CashAction.ts    From cashcash-desktop with MIT License 5 votes vote down vote up
@BeforeInsert()
    beforeInsert() {
        this.attachAccount();
    }
Example #29
Source File: CashFilter.ts    From cashcash-desktop with MIT License 5 votes vote down vote up
@BeforeInsert()
    beforeInsert() {
        this.attachAccount();
    }