mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
[firestore][js] First pass of javascript implementation
This commit is contained in:
@@ -5,6 +5,7 @@ import { Platform } from 'react-native';
|
||||
|
||||
// modeled after base64 web-safe chars, but ordered by ASCII
|
||||
const PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
|
||||
const AUTO_ID_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
const hasOwnProperty = Object.hasOwnProperty;
|
||||
const DEFAULT_CHUNK_SIZE = 50;
|
||||
|
||||
@@ -373,3 +374,16 @@ export function promiseOrCallback(promise: Promise, optionalCallback?: Function)
|
||||
return Promise.reject(error);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a firestore auto id for use with collection/document .add()
|
||||
* @return {string}
|
||||
*/
|
||||
export function firestoreAutoId(): string {
|
||||
let autoId = '';
|
||||
|
||||
for (let i = 0; i < 20; i++) {
|
||||
autoId += AUTO_ID_CHARS.charAt(Math.floor(Math.random() * AUTO_ID_CHARS.length));
|
||||
}
|
||||
return autoId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user