
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
datastore-sequences
Advanced tools
Generate sequential numbers (auto-increment IDs) in Google Cloud Datastore.
Common wisdom is that you can't or at least shouldn't sequentially number records/rows/entities on Google Cloud Datastore. For background see 1, 2, 3, 4 and 5.
While this is sound advice in most cases, there are situations where you need to have sequential numbered things - e.g. invoice numbers.
datastore-sequences
implements a battle tested approach for slow but save sequence numbering.
There is a strong guarantee that that no ID will be produced more than once.
There is no guarantee that there will never be gaps in the numbering sequence. But this should happen extremely seldom.
Thew usage of different Prefixes allows you to have multiple independent sequences.
To use it, you instantiate with a @google-cloud/datastore instance and call allocateId:
import { Datastore } from '@google-cloud/datastore';
import { SequenceNumbering } from 'datastore-sequences';
const numbering = new SequenceNumbering(new Datastore());
const newId1 = await numbering.allocateId();
const newId2 = await numbering.allocateId();
console.log(newId1, newId2)
'1' '2'
This automatically reties getting a new number on datastore congestion and tries to serialize number generation to avoid datastore congestion.
You can give a prefix to get different namespaces:
const newIds = await Promise.all([
numbering.allocateId('RG'),
numbering.allocateId('LS'),
numbering.allocateId('RG'),
numbering.allocateId('LS')])
console.log(newIds);
['RG1' 'LS1', 'RG2', 'LS2']
You are also encouraged to give a starting value. This is only needed on the first run for a given Prefix:
const newIds = await Promise.all([
numbering.allocateId('RG', 10000),
numbering.allocateId('RG'),
]);
console.log(newIds);
[('RG10001', 'RG10002')];
FAQs
Generate sequential counters for Google Clound Datastore.
We found that datastore-sequences demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.