Write a row



get /

  noteID *String

Add hashids library to generate unique keys:

cd src/html/post-notes
npm i hashids

Implement a function to save a note:

// src/html/post-notes/index.js
let arc = require('@architect/functions')
let data = require('@architect/data')
let Hashids = require('hashids')

function getID() {
  let hashids = new Hashids
  let epoch = - 1525066366572
  return hashids.encode(epoch)

async function handler(req, res) {
  let noteID = getID()
  let body = req.body.body
  let title = req.body.title
  let ts = new Date(
  let note = await data.notes.put({noteID, body, title, ts})
    location: '/'

exports.handler = arc.http(handler)

The function defines getID helper. Internally the function uses a custom UNIX epoch by hardcoding an app specific start value. The value returned is a very short and unique key that is also URL safe.

Next: update