Skip to content

Why not treat undefined the same as null? #15

@nmaves

Description

@nmaves

Curious why there is an explicit null check in the toString(). Why not treat undefined the same as null and use ''? You can see a pattern that we use a lot in our code and it fails because the map at the end returns undefined.

  return new RedisDataLoader(
    'prefix',
    new DataLoader(
      async (ids) => {
        const results = await pool.query(
          `select * from foo where id = any($1)
        `,
          [ids],
        )

        const keyById = keyBy(results.rows, 'id')

        return ids.map((id) => keyById[id])
      },
      { cache: false },
    ),
    {
      ONE_HOUR,
    },
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions