Short incremental uinque id for neo4j
问题 I use django with neo4j as database. I need to use short url based on node ids in my rest api. In neo4j there is an id used in database that didn't recommended to use in app, and there is approach to use uuid that is too long for my short urls. So I add my uid generator: def uid_generator(): last_id = db.cypher_query("MATCH (n) RETURN count(*) AS lastId")[0][0][0] if last_id is None: last_id = 0 last_id = str(last_id) hash = sha256() hash.update(str(time.time()).encode()) return hash