Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Industrial
    @industrial:matrix.org
    [m]
    I tried this:
      database: {
        type: 'postgres',
        host: process.env.POSTGRES_HOST,
        port: Number(process.env.POSTGRES_PORT),
        username: process.env.POSTGRES_USER,
        password: process.env.POSTGRES_PASSWORD,
        database: process.env.POSTGRES_DATABASE,
        namingStrategy: {
          tableName: (targetName: string, userSpecifiedName?: string): string => {
            return targetName.toLowerCase()
          },
        },
      },
    Didn't work ☹️
    When I log inside the function, it isn't called.
    Maciej Maciaszek
    @memee
    Hello, I cannot delete an entity with many-to-many relationship on some environments (for example running in bitbucket pipelines). Here's minimal setup: https://gist.github.com/memee/040284bf8aa0931996fc5ad15e358f3d
    Prafull Kumar
    @Prafull1Kumar
    Some of my .addSelect('d.component_activity_id AS d_component_activity_id') while querying showing "d"."componentActivityIdId" AS "d_componentActivityIdId" this
    it is happening with every column name which is ending with _id
    Maxime Lafarie
    @maximelafarie
    Hi folks! I would like to know if you have some advices / articles about how to paginate data in TypeORM and how to process query params and run them against Model properties? :) (e.g. query params to filter a getMany by username)
    manish-sg
    @manish-sg

    Hi folks! I would like to know if you have some advices / articles about how to paginate data in TypeORM and how to process query params and run them against Model properties? :) (e.g. query params to filter a getMany by username)

    You can use the find methods with skip and offset to do basic pagination. There is also another library for pagination called typeorm-paginate (?) that I have not used but I did research it at one point

    Maxime Lafarie
    @maximelafarie

    Hi folks! I would like to know if you have some advices / articles about how to paginate data in TypeORM and how to process query params and run them against Model properties? :) (e.g. query params to filter a getMany by username)

    You can use the find methods with skip and offset to do basic pagination. There is also another library for pagination called typeorm-paginate (?) that I have not used but I did research it at one point

    thanks buddy!

    Maxime Lafarie
    @maximelafarie
    Hi again, I would like to know if it's possible to orderBy a JSONB property instead of a standard column?
    y-chen
    @y-chen
    Hello, I have this error: CustomRepositoryCannotInheritRepositoryError: Custom entity repository MyCustomRepository cannot inherit Repository class without entity being set in the @EntityRepository decorator but the custom repository has the @EntityRepository with appropriate entity
    y-chen
    @y-chen
    I solved that error, there was a recursive dependency somewhere. But not I get EntityNotFound :(
    Aaron Gray
    @AaronNGray
    I want to create a UseNet like relation where posts have multiple subposts of infinite depth.
    @Entity()
    export class Post {
        @PrimaryGenerateColumn()
        id : number;
        @...
        posts: Post[];
        ...
    };
    What relation do I use here ?
    A @ManyToMany and a @JoinTable ?
    @ManyToMany(type => Post, posts => post.posts)
    @JoinTable()
    Aaron Gray
    @AaronNGray
    Another question is how would I deconstruct a join table so it is explicitly specified so I can add extra members to it ?
    Aaron Gray
    @AaronNGray
    @pleerock Looks like the issue was close when there where still issues.
    Vinit Kantrod
    @vinitkantrod
    how can I retry connection for typeorm in nodejs. Is there any option to provide retry option?
    IROEGBU!
    @iroegbu
    Anybody else consistently facing this issue? typeorm/typeorm#3280
    I can't seem to find a workaround that works, I have to consistently delete generated queries.
    Roman Slonov
    @romanslonov

    Hello everyone,
    I have an entity that helps join two enteties User and Board, so I am trying to query all boards that shared with User:

    const user = await this.userRepository.findOne(1, {
          relations: [
            'boardsSharedWithYou',
            'boardsSharedWithYou.board',
            'boardsSharedWithYou.board.owner',
            'boardsSharedWithYou.board.files',
          ],
        });
    @Entity()
    export class SharedBoard {
      @PrimaryColumn()
      senderId: number;
      @ManyToOne(() => User, (user) => user.boardsYouShared)
      @JoinColumn({ name: 'senderId' })
      sender: User;
    
      @PrimaryColumn()
      targetId: number;
      @ManyToOne(() => User, (user) => user.boardsSharedWithYou)
      @JoinColumn({ name: 'targetId' })
      target: User;
    
      @PrimaryColumn()
      boardId: number;
      @ManyToOne(() => Board, (board) => board.shares)
      @JoinColumn({ name: 'boardId' })
      board: Board;
    }

    How can I exclude SharedBoard colums?

    [
      SharedBoard {
        senderId: 2,
        targetId: 1,
        boardId: 2,
        board: Board {
          id: 2,
          name: 'shared',
          createdAt: 2021-07-18T15:31:26.680Z,
          deletedAt: null,
          owner: [User],
          files: []
        }
      }
    ]
    Maciej Maciaszek
    @memee
    Hello, when I'm trying to createConnection() without params typeorm is trying to CREATE TABLE "typeorm_metadata" which already exists. I'm using env variable TYPEORM_SYNCHRONIZE: 'false',. Why is that?
    1 reply
    Maciej Maciaszek
    @memee
    I want to drop postgtres database. Is it possible to do it outside transaction? The only way I can do it right now is using pg lib.
    Abdelmottaleb Souli
    @alaso:matrix.org
    [m]
    Hi everyone, please does anyone have an example/ tutorial on how / best way to get TypeORM configs from AWS secret manager (DB_PASSWORD, DB_PORT, ...).
    thank you
    config typeORM db connection using some information stored on aws secrets manager: like DB_PASSWORD
    Thank you
    .
    y-chen
    @y-chen
    ConaGo
    @ConaGo
    Hello, is it possible to execute a TABLESAMPLE query with typeorm?
    y-chen
    @y-chen
    Hi, is it normal that typeorm creates M:M pivot tables without FK constraints?
    y-chen
    @y-chen
    How do I save a timestamp in GMT timezone? new Date() saves in my local timezone
    Alexandre Verri
    @alexandreverri_twitter
    Hello, I have one doubt about Typeorm inheritance. Is it possible to configure Typeorm to do table inheritance? For example, I have a concrete class User and another concrete class Mentor extends User. I want Mentor table to have the foreign key to User table, without duplicating all the columns of User. Typeorm is actually creating the table Mentor with all fields of User table, I don't want that.
    Jimin Park
    @jimin4
    I'm using TypeORM with PostgreSQL. When the database is restarted, TypeORM throws an error Error: Connection terminated unexpectedly and my server gets killed. Is there a way to properly handle DB connection retries? Could you please point me to a guide or example code that shows how to do this. I've been searching for couple hours but couldn't find what I wanted.
    fdxshadow
    @fdxshadow
    image.png
    image.png
    Hi everyone, i have a problem with a column with default value, when i try set this column, not work. I don't know what happend, the server not throw errors :C.
    Karl Clement
    @karlclement
    Getting the following error trying to generate migrations: TypeError: Class extends value undefined is not a constructor or null
    Aaron Gray
    @AaronNGray
    Hi, I am having issues on moving from Vesper, (which I dicovered is dead too late) to raw TypeORM, with the resolving of sub fields. Under Vesper and typeorm EntityManager subfields were resolved to GraphQL queries to TypeORM structures. I have tried using EntityManager with TypeORM instead of the individual classes, but am getting null's returned for the subfeilds still. Is the subfield resolution a feature of Vesper or am I doing something wrong with TypeORM ?
    Is it Vespers @Controllers and @Query's giving the sub-field resolution where as TypeORM require manual resolution in its @Resolver's and @Query's ?
    Brian Kimball
    @bvkimball
    Hi not sure if this is a MSSQL problem or a typeorm config issue, but i am getting a "QueryFailedError: Error: Timeout: Request failed to complete in 15000ms" where i perform multiple requests in a @BeforeInsert() method. The first query works and the second timesout, its not a problem with the query because it works if i switch the order of the query, first query works then second timesout. I switched these to getConnection().query(rawQuery) in an attempt to get something to work. Anyone have a similar issue?
    vc-alphaswap
    @vc-alphaswap

    hey everyone,
    I'm new to typeorm, and a bit stuck

    I have a migration with query runner

    await queryRunner.query(`
          CREATE TYPE ${ns}.user_type_enum AS ENUM (
            'ADMIN',
            'USER',
            'CUSTOMER'
          );
    `);

    synchronize is false in config and we run migrations on npm start
    but once I'm doing npm start I'm getting an error QueryFailedError: type "user_type_enum" already exists

    not sure how to fix it. I already tried to drop DB and rerun but not it won't create tables because of that

    Varnit Sharma
    @LunaticProgrammer
    Hi, Can anyone tell me how to orderBy some date string like this "2021-08-27T09:47:18.377Z"
    papastepano
    @papastepano
    Hello! Does anyone know where I can find more information on storing geometry to database column other than Point?
    Aaron Gray
    @AaronNGray
    Having problems with login code
    function App() {
        const [ user, setUser ] = useState(false);
    
        return (
            <BrowserRouter>
                <Switch>
                    <Route exact path="/">
                        <Web user={user} setUser={setUser} />
                    </Route>
                    <ProtectedRoute exact path="/home" authed={!!user}>
                        <Home user={user} setUser={setUser} />
                    </ProtectedRoute>
                    <Route exact path="/login">
                        <Login setUser={setUser} />
                    </Route>
                </Switch>
            </BrowserRouter>
        );
    }
    export default function Login({ setUser }) {
        const [usernameOrEmail, setUsernameOrEmail] = useState();
        const [password, setPassword] = useState();
    
        const [login] = useMutation(LOGIN);
        const history = useHistory();
    
        const loginHandler = async e => {
            e.preventDefault();
            const { data } = await login({ variables: { usernameOrEmail, password} });
            setUser(data.login.user);
            history.push("/home");
        }
    
        return(
            <div className="login-wrapper">
                <h1>Please Log In</h1>
                <form onSubmit={loginHandler}>
                    <label>
                        <p>Username or email</p>
                        <input type="text" onChange={e => setUsernameOrEmail(e.target.value)} />
                    </label>
                    <label>
                        <p>Password</p>
                        <input type="password" onChange={e => setPassword(e.target.value)} />
                    </label>
                    <div>
                        <button type="submit">Submit</button>
                    </div>
                </form>
            </div>
        )
    }
    It keeps logging out on an F5, I presume I need to keep my state using localStorage ?
    Is there a good pattern for this ?
    Aaron Gray
    @AaronNGray
    Solved
    Konstantin Bodnia
    @qstyler

    Hi guys! Can someone please help me.
    I'm looking for a way to describe this sort of database:
    I have a table with names that I use for many entities:

    +-----------+--------------+------+-----+---------+----------------+
    | Field     | Type         | Null | Key | Default | Extra          |
    +-----------+--------------+------+-----+---------+----------------+
    | id        | int(11)      | NO   | PRI | NULL    | auto_increment |
    | entity    | varchar(255) | NO   |     | NULL    |                |
    | entity_id | bigint(20)   | NO   |     | NULL    |                |
    | name      | varchar(255) | NO   |     | NULL    |                |
    | alias     | tinyint(4)   | NO   |     | 0       |                |
    | langId    | int(11)      | YES  | MUL | NULL    |                |
    +-----------+--------------+------+-----+---------+----------------+

    so that I could run this query to get cities with language-specific names:

    select c.id, n.name
    from cities as c
             left join names as n
                       on true
                           and n.entity = 'city'
                           and c.id = n.entity_id
    where true
      and n.langId = 2
    limit 5

    the question is: how can I describe this relation in the database schema?