Code Monkey home page Code Monkey logo

Comments (1)

jvyden avatar jvyden commented on September 24, 2024

So, there's two ways I can see this going. Both are a little bit annoying to deal with.

The first is decently similar to what we currently do in Realm (as in, data is stored under one type). We have one table full of all comments, with the model having something like this:

public class GameComment
{
    public int? LevelId { get; set; }
    public ObjectId? ProfileId { get; set; }
    public int? PhotoId { get; set; } // (in the future)

    // ...
}

I like this, but it comes with the advantage of bloating up the model a bit, and it becomes a bit janky in regards to retrieving the host object and serializing it. We already have a system like this for Events, and to be frank it's a bit of a pain to deal with both internally and in refresh-web.

The other approach to use is having multiple tables. So, instead of storing multiple host object keys in the first approach, we have a dedicated table & class for each time a comment can be posted to an object:

public interface IComment
{
    // ...
}

public class ProfileComment : IComment
{
    public GameUser? Profile { get; set; }
}

public class LevelComment : IComment
{
    public GameLevel? Level { get; set; }
}

public class PhotoComment : IComment
{
    public GamePhoto? Photo { get; set; }
}

Maybe we could have it be IComment<THost> or something to keep API response types or w/e simple, but that's the idea. This comes at the cost of having to juggle multiple tables but I think that's better than juggling different keys on one table.

I lean towards the second approach, personally.

from refresh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.