Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

243
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!