bulk write operations $pull not supports list of ObjectIDs / UUIDs

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: 6.15.0, 6.16.0
    • Component/s: Bulk API
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Use Case

      As a... developer
      I want... bulk write $pull operations to arrays of UUIDs & ObjectIDs
      So that... I do not have to use @ts-expect-error

      User Experience

      • What is the desired/expected outcome for the user once this ticket is implemented?
        To be able to $pull from lists of ObjectIDs and UUIDs
      • If bug: What is the number of impacted customers? How severe is the impact? Is anyone blocked or broken?
        Low. Since the problem is with the typescript types

      Dependencies

      • upstream and/or downstream requirements and timelines to bear in mind
        Not to my knowledge.

      Risks/Unknowns

      • What could go wrong while implementing this change? (e.g., performance, inadvertent behavioral changes in adjacent functionality, existing tech debt, etc)
      • Is there an opportunity for better cross-driver alignment or testing in this area?
      • Is there an opportunity to improve existing documentation on this subject?

      Acceptance Criteria

      Implementation Requirements

      • functional reqs, potential snafus to avoid, performance targets, etc

      Testing Requirements

      • unit test, spec test sync, etc
        Unit tests can be made to make sure that types are behaving correctly

      Documentation Requirements

      • DOCSP ticket, API docs, etc

      Follow Up Requirements

      • additional tickets to file, required releases, etc
      • if node behavior differs/will differ from other drivers, confirm with dbx devs what standard to aim for and what plan, if any, exists to reconcile the diverging behavior moving forward

      More details

      I have created a GitHub repository showcasing the problem: https://github.com/aifrim/aifrim-mongodb-bulk-write-pipeline-pull 

      The main issue is that, given a collection that respects this schema

      type Schema {
         _id: ObjectId;
         listOfObjectIds: ObjectId[];
         listOfUUIDs: UUID[];
         listOfstrings: string[]
      }

      Within bulk operations you will have a type error when you will want to $pull from a list of ObjectIDs/UUIDs

      ObjectId: 

      {
         // Dave is no longer friends with Alice and Bob
         updateOne: {
           filter: { name: "Dave" },
           update: {
             $pull: {
               friends: { $in: [alice._id, bob._id] },
             },
           },
         },
       },
      

      Error

      Object literal may only specify known properties, and '$in' does not exist in type 'Partial<ObjectId> | { readonly _bsontype?: FilterOperators<"ObjectId"> | undefined; id?: FilterOperators<Uint8Array<ArrayBufferLike>> | undefined; ... 5 more ...; inspect?: FilterOperators<...> | undefined; }'.ts(2353)

      UUIDs

      {
        // Alice & Bob left the session
        updateMany: {
          filter: { name: { $in: ["Alice", "Bob"] } },
          update: {
            $pull: {
              sessions: { $in: [SAME_SESSION] },
            },
          },
        },
      },
      
      Object literal may only specify known properties, and '$in' does not exist in type 'Partial<UUID> | { id?: FilterOperators<Uint8Array<ArrayBufferLike>> | undefined; toHexString?: FilterOperators<(includeDashes?: boolean | undefined) => string> | undefined; ... 18 more ...; toBits?: FilterOperators<...> | undefined; }'.ts(2353) 

      Maybe this also happens to other operators?

       

            Assignee:
            Unassigned
            Reporter:
            Alexandru Ifrim
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: