in firestore/solution-sharded-timestamp/shardedTimestamps.js [38:85]
async function insertData() {
const instruments = [
{
shard: randomShard(), // add the new shard field to the document
symbol: 'AAA',
price: {
currency: 'USD',
micros: 34790000
},
exchange: 'EXCHG1',
instrumentType: 'commonstock',
timestamp: Timestamp.fromMillis(
Date.parse('2019-01-01T13:45:23.010Z'))
},
{
shard: randomShard(), // add the new shard field to the document
symbol: 'BBB',
price: {
currency: 'JPY',
micros: 64272000000
},
exchange: 'EXCHG2',
instrumentType: 'commonstock',
timestamp: Timestamp.fromMillis(
Date.parse('2019-01-01T13:45:23.101Z'))
},
{
shard: randomShard(), // add the new shard field to the document
symbol: 'Index1 ETF',
price: {
currency: 'USD',
micros: 473000000
},
exchange: 'EXCHG1',
instrumentType: 'etf',
timestamp: Timestamp.fromMillis(
Date.parse('2019-01-01T13:45:23.001Z'))
}
];
const batch = fs.batch();
for (const inst of instruments) {
const ref = fs.collection('instruments').doc();
batch.set(ref, inst);
}
await batch.commit();
}