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

Store Movies/Series #22

Open
KenavR opened this issue Oct 16, 2017 · 3 comments
Open

Store Movies/Series #22

KenavR opened this issue Oct 16, 2017 · 3 comments

Comments

@KenavR
Copy link
Member

KenavR commented Oct 16, 2017

Dependencies:

Write a function that consumes the result of Create Movie/Series/Episode objects (#21) and stores it correctly to the data store.

@sushma-priyadharssini
Copy link
Contributor

If we are implementing creation of Movie/Series/Episode objects in a single function, how can we identify the object as Movie/Series/Episode and add to the corresponding table in db. Is the only way to compare object structure or is there something else that am missing?

@KenavR
Copy link
Member Author

KenavR commented Oct 2, 2018

I am sorry, since I have written these tasks quite some time ago, I need to get back into the mindset of one year ago.

The creation function (#21) is a single function because it gets its input from the filesystem. In the filesystem we only have the filepath to go on, then the creation function "decides" if the file is a movie or an episode of a series. (I don't think we came up with a good detection last year) The creation function (#21) then turns that list of files into corresponding mongoose Series, Episode and Movie objects.

The result is then fed into this store function (#22). Since there is a save function on mongoose objects (I guess I didn't remember that last year) it just calls save on each found object.

I guess we need to first implement the dependencies to work on this issue. There is a suggested PR for #19 I will look into.

Let me know if that was too complicated, I am sure I can explain it differently.


I will answer your initial question, though I don't think we will need to identify the objects since the objects save function should store it in the right collection anyway.

We could have identified the objects either

  1. Looking at the object's properties (Data Models #6) - (would be hacky I guess) or

  2. use instanceof (mdn) - This should work with mongoose objects

@sushma-priyadharssini
Copy link
Contributor

Here we have different collections for series and movies. That's why i thought we might have to identify objects. Anyways I'll try to work on this considering your suggestions.

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