RxDb - Delete object from array with specific index

218 views Asked by At

It gives me a head-ache seeing all solutions using $pull in MongoDb that RxDb inspire it's queries I started looking into docs I saw that RxDb uses modifyjs. Yee... it doesn't support $pull operator so it leaves only with $unset but it works only with object property, not deleting whole object. There is my json-schema:

const sectionSchema = {
  keyCompression: true,
  version: 0,
  type: 'object',
  properties: {
    sectionTitle: {
      type: 'string',
    },
    lessons: {
      type: 'array',
      default: [],
      items: {
        type: 'object',
        properties: {
          lessonTitle: {
            type: 'string',
          },
        },
      },
    },
  },
};

This my closest solution but it deletes all lessons instead of one.

    doc.update({
        $unset: {
          lessons: {
            [`${lessonKey}`]: this.lessons[lessonKey],
          },
        }
})

Thanks for any help.

0

There are 0 answers