Giter Site home page Giter Site logo

nothinkdb's People

Contributors

ironhee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nothinkdb's Issues

Example in readme.md does not work

When running the example in the readme as-is, I see the following error:

ValidationError: {
  "table": "user",
  "tableName" [1]: -- missing --
}

ok... after changing table to tableName, the error disappears but nothing else happens (I'm expecting to see the newly created users in the console).

The example from rethinkdb works fine.

Add practical examples.

  • basic relation examples
    • hasOne
    • belongsTo
    • hasMany
    • belongsToMany
  • extending examples
    • Table
  • todo example

Rooms for improvement

Structural

  • Table#create and Table#attempt are duplicate.
  • Why should Table#insert must be accompanied by Table#create? Schema that is passed in the constructor is only good for Table#create where Table#insert is just a raw rethinkdb insert. Table#insert should call Table#create with schema before inserting in the database.
  • Why should link be exposed? Suggestion:
// before
bar: hasOne(fooTable.linkedBy(barTable, 'fooId'))
bar: belongsTo(fooTable.linkTo(barTable, 'barId'))
bars: hasMany(fooTable.linkedBy(barTable, 'fooId'))
// after
bar: hasOne(barTable, 'fooId')
bar: belongsTo(barTable, 'barId')
bars: hasMany(barTable, 'fooId')
  • Table#createRelation has inconsistent spec.
// before
fooTable.createRelation('bar', foo.id, bar.id)
// after
fooTable.createRelation(foo.id, 'bar', bar)
  • Table#createRelation should accept other object instead other.id. Table#foreignKey can be any other field than pk, and for Table#createRelation of belongsTo, right.table.get(otherPk) must be fetched with foreignKey that is not necessarily pk.

Test

  • After tests are run, tables are still there. Whatever created during test must be cleared after.
  • Bi-direction relationship is not tested.
  • Table#withJoin is not tested with relations as object. I'm not even sure what it does.

Implementation Questions

  • In relations.js, what's the point of these:
apply = query => query;

query = r.branch(
  row(right.field),
  query.getAll(row(right.field), { index: left.field }),
  r.expr([]),
);

Code still works with apply and branch.

Create Environment class.

create Environment class.

const env = new Environment();
const fooTable = env.createTable({ ... });

await env.sync()  // sync all tables
env.getTable('foos');  // same as fooTable
env.getTableList('foos');  // [...]

rethinkdb to rethinkdbdash ?

They are quite similar but the second offer much more options and is developped by someone on the RethinkDB team.

Could it be possible to use this instead?

Make sync return query

Now, Table.sync & Environment.sync receive connection as argument.
Change that functions return query, For it could be used with another ecosystem like rethinkdb-pool.

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.