Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of a separate table to store the likes #3

Open
Juice10 opened this issue Jun 14, 2017 · 2 comments
Open

Use of a separate table to store the likes #3

Juice10 opened this issue Jun 14, 2017 · 2 comments
Assignees

Comments

@Juice10
Copy link
Contributor

Juice10 commented Jun 14, 2017

In non-atomic databases like CouchDB storing all users in the same DB record can lead to lost favorites due to race conditions.

What would be better is for these types of database is to store each individual like as a separate record. That way you don't run into this issue as much.

We might have to rename likes in the mixin configuration to something more descriptive.

Options Type Requried Possible Values Examples
likesModel String No Model name Like, Favorite, etc. can not be used together with likesAttribute
likesAttribute String No Any Model property name with Object type when not using likesModel
@jonathan-casarrubias
Copy link
Collaborator

@Juice10 thanks for reaching out, hey so... yes I thought at some point in doing that is just that I haven't used this module in a while, therefore I have been unable to improve it.

I usually keep improving and making bigger modules that my current projects requires, but unfortunately this has not been a requirement in a while, so.... If you are able to send a pull request adding this feature would be cool, otherwise I would need to find some time at some point to implement that.. But not sure it will be like really soon..

Thoughts?

@Juice10
Copy link
Contributor Author

Juice10 commented Jun 19, 2017

@jonathan-casarrubias Thanks for the response!
Because of the CouchDB requirements I had I ended up creating a Like model and adding it as a relation to my models like so:

  "relations": {
    "likes": {
      "type": "hasMany",
      "model": "Like",
      "foreignKey": ""
    }
  },

It seemed like the easier way to do it than rewriting loopback-likes-mixin since I don't have that much experience writing loopback mixins as of now. I really do like the plugin you created and love the ease of use setting it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants