Fix create doc (#2672)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-02-21 18:22:15 +06:00 committed by GitHub
parent 117f9f291a
commit dae9de4800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 34 deletions

View File

@ -45,10 +45,7 @@
// date = new Date().getTime() + value.shift
// }
if (date === undefined) return
const _id = await client.createDoc(calendar.class.Event, space, {
attachedTo,
attachedToClass,
collection: 'reminders',
const _id = await client.addCollection(calendar.class.Event, space, attachedTo, attachedToClass, 'reminders', {
date,
description: '',
participants,

View File

@ -36,13 +36,13 @@
async function onMessage (event: CustomEvent) {
const { message, attachments } = event.detail
const me = getCurrentAccount()._id
await client.createDoc<Message>(
await client.addCollection(
_class,
space,
space,
chunter.class.ChunterSpace,
'messages',
{
attachedTo: space,
attachedToClass: chunter.class.ChunterSpace,
collection: 'messages',
content: message,
createOn: Date.now(),
createBy: me,
@ -59,12 +59,9 @@
chunterSpace.members
.filter((accId) => accId !== me)
.map((accId) =>
client.createDoc(notification.class.LastView, space, {
client.addCollection(notification.class.LastView, space, space, chunterSpace._class, 'lastViews', {
user: accId,
lastView: 0,
attachedTo: space,
attachedToClass: chunterSpace._class,
collection: 'lastViews'
lastView: 0
})
)
)

View File

@ -195,13 +195,17 @@
const reaction = reactions?.find((r) => r.emoji === emoji && r.createBy === me)
if (!reaction) {
await client.createDoc(chunter.class.Reaction, message.space, {
attachedTo: message._id,
attachedToClass: chunter.class.ChunterMessage,
emoji,
createBy: me,
collection: 'reactions'
})
await client.addCollection(
chunter.class.Reaction,
message.space,
message._id,
chunter.class.ChunterMessage,
'reactions',
{
emoji,
createBy: me
}
)
} else {
await client.removeDoc(chunter.class.Reaction, message.space, reaction._id)
}

View File

@ -152,13 +152,13 @@
async function onMessage (event: CustomEvent) {
const { message, attachments } = event.detail
const me = getCurrentAccount()._id
await client.createDoc(
await client.addCollection(
chunter.class.ThreadMessage,
currentSpace,
_id,
chunter.class.Message,
'replies',
{
attachedTo: _id,
attachedToClass: chunter.class.Message,
collection: 'replies',
content: message,
createBy: me,
createOn: Date.now(),

View File

@ -41,10 +41,7 @@
} else if (status && !newStatus) {
client.removeDoc(contact.class.Status, status.space, status._id)
} else {
client.createDoc(contact.class.Status, employee!.space, {
attachedTo: employeeId,
attachedToClass: contact.class.Employee,
collection: 'statuses',
client.addCollection(contact.class.Status, employee!.space, employeeId, contact.class.Employee, 'statuses', {
name: newStatus.name,
dueDate: newStatus.dueDate
})

View File

@ -62,7 +62,8 @@
async function createCustomer () {
const candidate: Data<Contact> = {
name: formatName(targetClass._id, firstName, lastName, object.name),
city: object.city
city: object.city,
createOn: Date.now()
}
if (avatar !== undefined) {
candidate.avatar = await avatarEditor.createAvatar()

View File

@ -129,16 +129,16 @@
async function onMessage (event: CustomEvent) {
if (channel === undefined) return
const { message, attachments } = event.detail
await client.createDoc(
await client.addCollection(
telegram.class.NewMessage,
telegram.space.Telegram,
channel._id,
channel._class,
'newMessages',
{
content: message,
status: 'new',
attachments,
attachedTo: channel._id,
attachedToClass: channel._class,
collection: 'newMessages'
attachments
},
objectId
)