Delete mutation

I know the deletion is not supported currently, but my app needs this and I am seeking the best solution to deal with this requirement.
I have Profile and Follow models, when a profile follows another, a follow data is created, but when they unfollow, we cannot delete that follow so the relation and relation count are now incorrect. I am not sure what is the best way to deal with this problem.
I ended up adding a “status” property in the Follow model and set it to “ACTIVE” on created, and when the user unfollows, update it to “INACTIVE”, and on the UI I filter out the “INACTIVE” items. This works, but the UI has to do the heavy logic and I am looking for a better solution. Any suggestions? Please.

Here are the models.

type Profile
  @createModel(
    accountRelation: SINGLE
    description: "A profile of an account"
  ) {
  name: String! @string(minLength: 3, maxLength: 64)
}

type Follow
  @createModel(accountRelation: LIST, description: "A follow of a profile") {
  followerId: StreamID! @documentReference(model: "Profile")
  follower: Profile! @relationDocument(property: "followerId")
  followingId: StreamID! @documentReference(model: "Profile")
  following: Profile! @relationDocument(property: "followingId")
  status: Status!
}

enum Status {
   ACTIVE
   INACTIVE
}

And this is the relation.

type Follow @loadModel(id: "$FOLLOW_ID") {
  id: ID!
}

type Profile @loadModel(id: "$PROFILE_ID") {
  followers: [Follow]! @relationFrom(model: "Follow", property: "followerId")
  followersCount: Int! @relationCountFrom(model: "Follow", property: "followerId")
  following: [Follow]! @relationFrom(model: "Follow", property: "followingId")
  followingCount: Int! @relationCountFrom(model: "Follow", property: "followingId")
}
1 Like

@spencer this is an old post but we are looking into implementing this as well. I believe we discussed a way to mark a stream as deleted using the metadata during one of the core devs meeting but i can’t find this info in the forum.

Can you share how to achieve this again?

Thanks!

So there’s still no way to do actual deletion, but there is now a new shouldIndex flag in metadata which can be used as a signal to indexers (such as OrbisDB and ComposeDB) that they should remove the stream from the index and stop returning its data in queries. More information available in our recent feature announcement: Ceramic Feature Release: SET Account Relations, Immutable Fields and shouldIndex flag