This commit is contained in:
@ -12,12 +12,15 @@ import {
|
||||
} from "./query";
|
||||
import Logging from "@hibas123/nodelogging";
|
||||
import Session from "./session";
|
||||
import nanoid = require("nanoid/generate");
|
||||
import nanoid = require("nanoid");
|
||||
import { Observable } from "@hibas123/utils";
|
||||
|
||||
const ALPHABET =
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
const longNanoId = nanoid.customAlphabet(ALPHABET, 32);
|
||||
const shortNanoId = nanoid.customAlphabet(ALPHABET, 16);
|
||||
|
||||
// interface ITransaction {
|
||||
// queries: ITypedQuery<IWriteQueries>[];
|
||||
// }
|
||||
@ -156,7 +159,7 @@ export class Database {
|
||||
.then((r) => r.toString())
|
||||
.catch(resNull);
|
||||
if (!collectionID && create) {
|
||||
collectionID = nanoid(ALPHABET, 32);
|
||||
collectionID = longNanoId();
|
||||
await this.collections.put(key, collectionID);
|
||||
setImmediate(() => {
|
||||
this.collectionChangeListener.send({
|
||||
@ -329,7 +332,7 @@ export class Database {
|
||||
|
||||
const { unsubscribe, value } = await query.snapshot(onchange);
|
||||
|
||||
const id = nanoid(ALPHABET, 16);
|
||||
const id = shortNanoId();
|
||||
session.subscriptions.set(id, unsubscribe);
|
||||
return {
|
||||
id,
|
||||
|
Reference in New Issue
Block a user