Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
how to generate a short id to use as key on dynamodb?

I need to create IDs to use as key on DynamoDB. Checked https://github.com/uuidjs/uuid but the ids generated are too long to be remembered. how can I generate shorter ones like the ones from youtube video Id.

Also do I really need to specify a Key or Dynamo can create one automatically for me just like firebase firestore for example?

My code:

var db = new AWS.DynamoDB.DocumentClient();
var student = {
  TableName: "students",
  Item: {
    id: "abc123",
    name: "Mia",
  },
};

db.put(student)
  .promise()
  .then((response) => console.log(response))
  .catch((err) => console.log(err));
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

It sounds like you want to build a URL Shortener. There are loads of tutorials online showcasing how to do this in AWS using DynamoDB and API Gateway, so you might want to search online for a more detailed walkthrough.

how can I generate shorter ones like the ones from youtube video Id

You'll need to generate this yourself in your application code. If you're using javascript, you could use something like this, which creates a random string:

  let short_id = (Math.random() + 1).toString(36).substring(7);

Keep in mind that you'll need to include retry logic in the event the generated ID is not unique in the database.

do I really need to specify a Key or Dynamo can create one automatically for me just like firebase firestore for example?

DynamoDB will not automatically create or manage ID's for your application. You'll need to do this yourself.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use nanoid which is similar to uuid, u can use specify length of ID u want

const { nanoid } = require('nanoid')

var db = new AWS.DynamoDB.DocumentClient();
var student = {
  TableName: "students",
  Item: {
    id: nanoid(), // or nanoid(10) for 10 char id
    name: "Mia",
  },
};

db.put(student)
  .promise()
  .then((response) => console.log(response))
  .catch((err) => console.log(err));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda