const generateReaction = (userId, messageId) => { return { id: uuid(), messageId, userId, timestamp: faker.date.past(2), type: 'like', }; }
/* global ml,jetpackMailerliteSettings */ ( function () { window.ml_account = ml( 'accounts', jetpackMailerliteSettings.account, jetpackMailerliteSettings.uuid, 'load' ); } )();
addToForeignTableSchema(table, { path, isUnique, isIndexed, isNotNullable }) { if (!this.field.isPrimaryKey) { throw ( `Can't create foreign key '${path}' on table "${table._tableName}"; ` + `'${this.path}' on list '${this.field.listKey}' as is not the primary key.` ); } const column = table.uuid(path); if (isUnique) column.unique(); else if (isIndexed) column.index(); if (isNotNullable) column.notNullable(); }
uuid() { const token = { prefix: '{', suffix: '}', type: this.typeStr() || 'cljs.core.UUID', keywordPrefix: ':uuid'} return <ReplOutputCljsVal value={ReplOutput.clojure(this.value.uuid).view()} token={token} /> }
describe('uuid', () => { describe('uuid', () => { test('It should return a valid uuid', () => { const id = uuid(); expect(id).toBeDefined(); expect(id).toHaveLength(36); expect(id[8]).toEqual('-'); expect(id[13]).toEqual('-'); expect(id[18]).toEqual('-'); expect(id[23]).toEqual('-'); }); }); });
const generateDirectMessageThread = users => { const createdAt = faker.date.past(2); const threadLastActive = faker.date.between(createdAt, faker.date.recent()); return { id: uuid(), name: null, createdAt, threadLastActive, }; }
const generateCommunity = () => { const name = faker.company.companyName(); return { id: uuid(), createdAt: faker.date.past(2), name, description: casual.short_description(), website: faker.internet.url(), profilePhoto: faker.image.business(), coverPhoto: faker.image.image(), slug: slugify(name), }; }
addToTableSchema(table) { const column = table.uuid(this.path); // Fair to say primary keys are always non-nullable and uniqueness is implied by primary() if (this.field.isPrimaryKey) { column.primary().notNullable(); } else { if (this.isUnique) column.unique(); else if (this.isIndexed) column.index(); if (this.isNotNullable) column.notNullable(); } if (this.defaultTo) column.defaultTo(this.defaultTo); }
getConversation(id, autocreate = false) { const conversationId = id || uuid(); if (!this.conversations[conversationId] && autocreate) { this.conversations[conversationId] = { conversationId, history: [], }; } return this.conversations[conversationId]; }
const generateChannel = communityId => { const name = faker.commerce.department(); return { id: uuid(), communityId, createdAt: faker.date.past(2), name, description: casual.short_description(), slug: slugify(name), isPrivate: faker.random.boolean(), isDefault: false, }; }
async insertOne(name, item) { const id = uuid(); const cloned = { id, ...item }; const collection = await this.getCollection(name); collection[id] = cloned; await this.markToSave(name); return cloned; }
const generateUsersThreads = (threadId, userId) => { const createdAt = faker.date.past(2); return { id: uuid(), createdAt, threadId, userId, isParticipant: true, receiveNotifications: true, }; }
addToTableSchema(table) { const column = table.uuid(this.path); // Fair to say primary keys are always non-nullable and uniqueness is implied by primary() if (this.field.isPrimaryKey) { column.primary().notNullable(); } else { if (this.isUnique) column.unique(); else if (this.isIndexed) column.index(); if (this.isNotNullable) column.notNullable(); } if (this.defaultTo) column.defaultTo(this.defaultTo); }
addToForeignTableSchema(table, { path, isUnique, isIndexed, isNotNullable }) { if (!this.field.isPrimaryKey) { throw ( `Can't create foreign key '${path}' on table "${table._tableName}"; ` + `'${this.path}' on list '${this.field.listKey}' as is not the primary key.` ); } const column = table.uuid(path); if (isUnique) column.unique(); else if (isIndexed) column.index(); if (isNotNullable) column.notNullable(); }