Coder Social home page Coder Social logo

poe-db's Introduction

poe-db

Build Status

Relational database for Content.ggpk from Path of [email protected].

Requirements

python 3.4 for PyPoe

install

$ git clone --recursive https://github.com/eps1lon/[email protected]

# run in a python 3.4 virtualenv for PyPoE:
$ yarn install --production

# you might need to config PyPoE to find the Content.ggpk
$ yarn run load-content

# Be sure to set the necessary environment variables for the connection
$ yarn run db:build

Database Setup

# just to display what priviliges are needed
CREATE USER 'poedb'@'localhost' IDENTIFIED BY '***';
CREATE DATABASE poedb;
GRANT USAGE ON *.* TO 'poedb'@'localhost';
GRANT ALL PRIVILEGES ON `poedb`.* TO 'poedb'@'localhost';

environment variables

The following variables have to be set as environment variables in order to authenticate to the database (alternatively follow the instructions in .env.example):

  • POEDB_HOST
  • POEDB_USER needs the following privileges
    • drop/create host wide for db:create, db:drop
    • all read/write privileges for the specified db
  • POEDB_PW
  • POEDB_DB

Endpoints

/describe/:model_name

  • :model_name - in CamelCase singular
{
  attributes: Attribute[],
  belongsTo: Association[],
  hasMany: Association[],
  belongsToMany: Association[],
  asCollection: string, // table name
}

/find/:model_name

  • query params:
    • page - type: number, default: 1
    • page_size - type: number, default: 20
    • order - type: [AttributeName, 'ASC' | 'DESC'][]
    • withDescription - includes the /describe endpoint type: boolean, default: false
    • attributes - whitelist, type: AttributeName[]
    • where - plain js object, see http://docs.sequelizejs.com/manual/tutorial/querying.html#where

/find/:model_name/:id

  • :model_name - in CamelCase singular
  • :id - primary key
  • includes belongsTo and belongsToMany associations
{
  count: 1,
  rows: ModelInstance,
}

/find/:model_name

  • :model_name - in CamelCase plural
  • includes belongsTo associations
// Returns
{
  count: number,
  rows: ModelInstance[],
}

/describe/:model_name

  • :model_name - in CamelCase singular
// Returns
{
  attributes: Attribute[],
  belongsTo: Association[],
  hasMany: Association[],
  belongsToMany: Association[],
  asCollection: string, // table name
}

/scoped/:model_name/:scope_name

// Returns
ModelInstance[]

dev environment

The repository should contain the latest models. If they are out of date the package contains scripts to generate new ones. To do so run the following commands:

$ yarn install
$ yarn run dev:parseContent
$ yarn run dev:models

Remember to add and run migrations if necessary.

Patch workflow

Dev workflow in case the spec in Content.ggpk changes (i.e. a patch hits): Wait for spec update in OmegaK2/PyPoE or change submodule and file a PR.

$ yarn run load-content
$ yarn run dev:models --poe $POE_CLIENT_VERSION
$ yarn run db:schema
$ yarn run db:migration:generate # adjust for renames
# verify generated migrations use diff between models as a helper
$ yarn run db:migration:run up
$ yarn run db:insert
$ yarn run test # mainly for scope tests

models

The models in src/models/base are auto generated. For specific scopes, getters, setters etc create or update the specific files in the corresponding folders.

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.