Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

242
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda