在Firestore中按具有动态ID的子集合排序

时间:2018-07-18 01:41:42

标签: firebase google-cloud-firestore

我的firestore收藏看起来像这样

const str = 'adfsaf @ adsfsad @ja!2123afd @eeeav @asedf';
const position = 20; // just after @ja, str[20] gives the space ' ' after @ja
const placeholder = '@ja'; // you should be able to get that dynamically.
const username = 'Jason Smith';  // you should be able to get that dynamically.

const idx = str.substring(0,position).indexOf(placeholder);
const output = `${str.substring(0,position - placeholder.length)}@${username} ${str.substring(position)}`;
console.log(output);

现在,我尝试在最后一个子集合c3中按值时间戳对a1,a2 ...进行排序(假设c1,c2 ..始终按降序排列)。但是问题是id c1,c2等是动态的,但是id b1是恒定的。 我知道我可以通过将 timestamp 复制到集合b1中来轻松解决此问题,但是确实可以这样做。

0 个答案:

没有答案