Skip to content

plemmy client pattern #22

@gwbischof

Description

@gwbischof

Because a post always has a community:
https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/post.rs#L25
And a comment always has a post:
https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/comment.rs#L24

Maybe the pattern that is used in pymongo would work well here, I think it would simplify using plemmy.
https://pymongo.readthedocs.io/en/stable/tutorial.html
And users wouldn't have to think about the plemmy.response types like GetComunityResponse

from plemmy import PlemmyHTTP
client = PlemmyHTTP("https://lemmy.ml")
community = client['community_name']  or client.get_community(name=community_name)
community.create_post(post)
post = community[post_id] or community.get_post(post_id)
post.create_comment(comment)

You could still do:

client.create_post(community_id, post)

What do you think?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions