Database Collections

From Seltanikor
Jump to: navigation, search

This page documents the collections (tables) that Tworld manages in MongoDB.

config

General server configuration and miscellaneous values.

  • _id
  • key (indexed)
  • val (ad-hoc format)

keys are...

  • dbversion: 6 (for this description)
  • playerfields: contains {desc, pronoun} copied to new *players
  • globalscopeid: scid of the single global scope (from *scopes)
  • startworldid: wid of the starting (solo) world (from *worlds)
  • startworldloc: loc key of start location in startworld
  • firstportal: {wid, scid, locid} for a player's first portlist entry (if absent, startworld is used)
  • noregistration: if true, player registration is not allowed
  • nologin: if true, player login is not allowed (except for admin accounts)
  • lastactive: the timestamp of the last time the tworld server was known to be running

localize

Server text customization. This is where we replace the generic Tworld text with Myst-specific flavor. This table also supports internationalization, although Seltani does not have any yet.

  • _id
  • key
  • lang (None for all-language default)
  • client (optional, True if relayed to client)
  • val
  • (no indexes, because we're going to load this stuff up at launch time) (but logically, it's a compound index on key, lang)

sessions

Web sessions. When a player signs in on the web site, they get a ten-day cookie which matches the sessionid. (Refreshed weekly as long as they're connected to the game.)

  • _id
  • sid: session id (generated by create_session()) (indexed, unique)
  • uid: _id from *players
  • email: from *players
  • name: from *players
  • ipaddr: request.remote_ip
  • starttime: time signed in
  • refreshtime: time that cookie was last refreshed
  • guest: True if this is a guest account (optional)

players

Player account records.

  • _id: uid
  • email: fixed at signup time (indexed, unique)
  • name: changeable by player (indexed, unique)
  • namekey: sluggified name (indexed; not unique, although we try to keep it unique)
  • admin: True for the admin (optional)
  • build: True if the player has build permission (optional)
  • askbuild: True if the player can request build permission via web form (optional)
  • guest: True if this is a guest account (optional) (indexed, sparse index)
  • guestsession: id from *sessions, if the guest account is logged in (optional)
  • pwsalt: added to password before hashing (generated by create_player())
  • password: hash of "pwsalt:password"
  • createtime: time signed up
  • scid: personal scope in *scopes
  • plistid: personal portlist (booklet) in *portlists
  • desc: as: (name is...) "an ordinary explorer."
  • pronoun: "he", "she", "it", "they", "name"

playstate

Current location of each player.

  • _id: uid (same as *players)
  • iid: _id from *instances
  • locid: _id from *locations
  • focus: symbol name or None
  • lastmoved: timestamp of last locale or world (not focus) change (optional)
  • lastlocid: locid of location moved from, or null if ported in (optional)
  • portto: { wid, scid, locid } (only present during porting, otherwise None)
  • (compound index on iid, locid) (nonunique)

playprefs

Player UI preferences.

  • _id
  • uid (indexed, not unique; used for aggregation for play.html template)
  • key
  • val (ad-hoc format)
  • (compound index on uid, key) (unique)

pwrecover

Password recovery requests ("I forgot my password").

  • _id: uid (same as *players)
  • key: random string (for URL) (indexed, unique)
  • createtime: time requested

worlds

Master records for worlds.

  • _id: wid
  • creator: uid (_id of player who built it)
  • name: as "Old District" (not necessarily unique!)
  • createtime: time created
  • copyable: bool
  • instancing: "solo", "shared", "standard"

locations

Locations within a world.

  • _id: locid
  • wid: _id from *worlds
  • key: py-key-compatible (as "ferry_dock") (must not be empty!)
  • name: as "Ferry Dock"
  • (compound index on wid, key) (unique)

scopes

Scopes (one global; one per player; eventually group scopes as well).

  • _id: scid
  • type: "pers", "glob", "grp"
  • group: name of group (only present for "grp") (not necessarily unique!)
  • uid: player of personal (only present for "pers")

scopeaccess

A player defaults to visitor for most scopes.

  • _id
  • uid: player
  • scid: scope
  • level: 0 (banned), 1 (visitor), 2 (member), 3 (owner), 4 (founder)
  • (compound index on uid, scid) (unique)

instances

Instances of a world.

  • _id: iid
  • wid: world
  • scid: scope
  • minaccess: minimum (scope) access level to enter (optional, defaults to visitor)
  • lastawake: None/absent if the instance has never been awake; True if it is currently awake; or a timestamp of the last time it slept
  • (compound index on wid, scid) (unique)

worldprop

Definitions of world-location properties. (As defined by the creator.)

  • _id
  • wid: _id from *worlds
  • locid: _id from *locations, or null for realm-wide
  • key (py-key-compatible)
  • val: ...
  • (compound index on wid, locid, key) (unique)

instanceprop

Instance values of location properties. Only exist if changed from the world def.

  • _id
  • iid: _id from *instances
  • locid: _id from *locations, or null for realm-wide
  • key (py-key-compatible)
  • val: ...
  • (compound index on iid, locid, key) (unique)

wplayerprop

Definitions of world-player properties.

  • _id
  • wid: _id from *worlds
  • uid: _id from *players, or null for all-players
  • key (py-key-compatible)
  • val: ...
  • (compound index on wid, uid, key) (unique)

iplayerprop

Instance values of player properties.

  • _id
  • iid: _id from *instances
  • uid: _id from *players, or null for all-players
  • key (py-key-compatible)
  • val: ...
  • (compound index on iid, uid, key) (unique)

trashprop

Discarded (world) properties. Kept for 24 hours.

  • _id
  • wid: _id from *worlds (indexed)
  • changed: date added (indexed)
  • origtype: 'worldprop' or 'wplayerprop'
  • locid: _id from *locations, or null for realm-wide (only for 'worldprop')
  • uid: _id from *players, or null for all-players (only for 'wplayerprop')
  • key (py-key-compatible)
  • val: ...

portlists

One for each player (the booklet); one for each bookshelf built in a world.

  • _id: plistid
  • type: "pers", "world"
  • uid: player owning this portlist (optional, only if personal)
  • wid: world containing this portlist (optional, only if world) (sparse index)
  • external: bool (optional; true if this portlist permits portal URLs)
  • key: (py-key-compatible) (optional, only if world)

portals

Every portal (linking book) is contained in a portlist (booklet or bookshelf).

  • _id: portid
  • plistid: portlist that the portal is in
  • iid: instance of portlist (will be None for world portals, personal portals) (must be an instance of the portlist's inwid for instance portals)
  • listpos: float (may be negative!) (optional, default 0)
  • preferred: bool (optional, only if in a player's portlist)
  • wid: world that the portal goes to
  • scid: scope that the portal goes to (or strings 'personal', 'global', 'same')
  • locid: location that the portal goes to
  • (compound index on plistid, iid)