Skip to content

Map support? #1

Open
Open
@bhj

Description

@bhj

Hi and thanks for the neat package. Any interest in adding support for Maps? They're nice to work with except for needing Array.from():

  const fields = new Map()
  fields.set('username', username.trim())
  fields.set('password', await bcrypt.hash(newPassword, 12))
  ...

  const query = sql`
    INSERT INTO users ${sql.tuple(Array.from(fields.keys()).map(sql.column))}
    VALUES ${sql.tuple(Array.from(fields.values()))}
  `

I think sqlate could handle the array conversion, with a few extra checks to stay ES5-compatible. Happy to submit a PR if you think it's a good idea?

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