How to use the @fullstack-one/db.Entity function in @fullstack-one/db

To help you get started, we’ve selected a few @fullstack-one/db examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fullstack-build / fullstack-one / examples / 2-orm-auth-graphql / models / Task.ts View on Github external
import { BaseEntity, Entity, Column, PrimaryGeneratedColumn, ManyToOne } from "@fullstack-one/db";
import { QueryPermissions, MutationPermissions } from "@fullstack-one/schema-builder";
import User from "./User";

@Entity()
@MutationPermissions({
  createViews: {
    me: {
      fields: ["title", "user"],
      expressions: "Anyone"
    }
  },
  updateViews: {
    me: {
      fields: ["id", "title", "user"],
      expressions: { name: "Owner", params: { field: "userId" } }
    },
    others: {
      fields: ["id", "user"],
      expressions: "Authenticated"
    }
github fullstack-build / fullstack-one / examples / 5-file-storage / models / User.ts View on Github external
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from "@fullstack-one/db";
import { Files } from "@fullstack-one/file-storage";
import { QueryPermissions, MutationPermissions } from "@fullstack-one/schema-builder";
import { anyone, owner } from "../expressions/basic";

@Entity({ schema: "public" })
@MutationPermissions({
  createViews: {
    me: {
      fields: ["name", "images"],
      expressions: anyone(),
      returnOnlyId: true
    }
  },
  updateViews: {
    me: {
      fields: ["id", "images"],
      expressions: owner({field: 'id'}),
      returnOnlyId: true
    }
  }
})
github fullstack-build / fullstack-one / examples / fullstack-one-example / models / Photo.ts View on Github external
import * as ORM from "@fullstack-one/db";

@ORM.Entity("Photo")
export class Photo extends ORM.BaseEntity {
  @ORM.PrimaryGeneratedColumn("uuid")
  public id: number;

  @ORM.Column()
  public name: string;

  @ORM.Column()
  public description: string;

  @ORM.Column()
  public filename: string;

  @ORM.Column()
  public views: number;
github fullstack-build / fullstack-one / examples / 2-orm-auth-graphql / models / Represent.ts View on Github external
import { BaseEntity, Entity, PrimaryGeneratedColumn, ManyToOne } from "@fullstack-one/db";
import { MutationPermissions, QueryPermissions } from "@fullstack-one/schema-builder";
import { anyone } from "../expressions";
import User from "./User";

@Entity()
@MutationPermissions({
  createViews: {
    me: {
      fields: ["prinzipal", "agent"],
      expressions: [anyone()]
    }
  }
})
export default class Represent extends BaseEntity {
  @PrimaryGeneratedColumn()
  public id: number;

  @ManyToOne((type) => User, "prinzipalRepresent")
  @QueryPermissions(anyone())
  public prinzipal: User;
github fullstack-build / fullstack-one / examples / 2-orm-auth-graphql / models / Photo.ts View on Github external
import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from "@fullstack-one/db";

@Entity({ schema: "public" })
export default class Photo extends BaseEntity {
  @PrimaryGeneratedColumn({ comment: "This is a very important id column." })
  public id: number;

  @Column({ gqlType: "String", type: "character varying" })
  public name: string;
}
github fullstack-build / fullstack-one / examples / 2-orm-auth-graphql / models / User.ts View on Github external
import Represent from "./Represent";

export enum Size {
  small,
  medium,
  large,
  superLarge
}

export enum Gender {
  male,
  female,
  diverse
}

@Entity()
@MutationPermissions({
  createViews: {
    me: {
      fields: ["firstname", "lastname"],
      expressions: anyone(),
      returnOnlyId: true
    }
  }
})
export default class User extends BaseEntity {
  @PrimaryGeneratedColumn()
  @QueryPermissions(anyone())
  public id: number;

  @Column({ gqlType: "String", type: "character varying" })
  public firstname: string;
github fullstack-build / fullstack-one / examples / 4-orm-computed-and-custom-columns / models / Task.ts View on Github external
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from "@fullstack-one/db";
import { Computed, Custom, QueryPermissions } from "@fullstack-one/schema-builder";
import { anyone, getTrue, getNumber, myId } from "../expressions";

@Entity({ schema: "public" })
export default class Task extends BaseEntity {
  @PrimaryGeneratedColumn({ comment: "This is a very important id column." })
  @QueryPermissions(anyone())
  public id: number;
  
  @Column({ gqlType: "String", type: "character varying" })
  @QueryPermissions(anyone())
  public title: string;

  @Computed({ ...getTrue(), gqlType: "Boolean" })
  @QueryPermissions(anyone())
  public solved: () => Promise;
  
  @Computed({ ...getNumber(), gqlType: "Int" })
  @QueryPermissions(anyone())
  public time: () => Promise;
github fullstack-build / fullstack-one / examples / 1-orm-basic / models / Task.ts View on Github external
import { BaseEntity, Entity, Column, Check, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from "@fullstack-one/db";

@Entity()
export default class Task extends BaseEntity {
  @PrimaryGeneratedColumn()
  public id: string;

  @CreateDateColumn()
  public readonly createdAt!: string;

  @UpdateDateColumn()
  public readonly updatedAt!: string;

  @Column({ gqlType: "String", type: "character varying", nullable: false })
  public title!: string;

  @Column({ gqlType: "String", type: "character varying", nullable: true })
  public solved?: string;
}