Skip to content

Comment on Reflections on MongoDBparent

Comments

Here's an example schema.

Users

    {
      _id:string //doubles for user's name
      password: {
        hash:string
        salt:string
      }
      website:string
      bio:string
      following:array of {
        username:string
        articles:boolean
        comments:boolean
      }
    }
Articles
    {
      _id:ObjectID //auto id
      title:string
      contents:string
      owner:string //references Users
      tags:array of strings //no reference, tags are either unfiltered or selected from a global tag list. 
    }
Comments
    {
      _id:ObjectID //auto id
      contents:string
      owner:string //references Users
      root:ObjectID //references Articles instead of Comments
      parents:array of ObjectIDs //using materialized path for threading of comments
    }
Config
    {
      _id:string
      value:? //untyped can store anything in json format
    }
Note: The references are defined entirely in software, the database is not aware of them.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.