Coder Social home page Coder Social logo

terence410 / ts-datastore-orm Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 4.0 219 KB

ts-datastore-orm targets to provide a strong typed and structural ORM feature for Datastore (Firestore in Datastore mode).

License: MIT License

TypeScript 99.83% JavaScript 0.17%

ts-datastore-orm's People

Contributors

terence410 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

Watchers

 avatar  avatar

ts-datastore-orm's Issues

How to work with entity relations?

I couldn't find any example for referencing an entity from another entity. Are relationships supported? Things like One-To-Many, Many-To-Many etc.

If not, is this something that is planned?

Best way of constructing objects

I came across this problem:

  • Can't create a constructor cause of this error "The 'this' context of type 'typeof MyEntity' is not assignable to method's 'this' of type 'typeof BaseEntity'.ts(2684)"

Should I set all properties as required and set a default empty state (empty string, 0, etc) or set all as nullable (with ?: operator)?

Or am I missing something about typescript? ๐Ÿค”

Thx for this "package"

Hi @terence410

first of all - a big thank you for writing and providing this package to the public. I know of the work behind an open source project - no matter of its size - a lot of work comes with the smallest projects.

The first things I've asked myself are the following:

  • In the README.md you write "Simple class structure using typescript decorator. (Very similar to type-orm)" - so why don't you use TYPEORM?
  • Do you plan to bring this project to a stable v1.0.0 ?
  • Is there anything "known" that would you prevent from using it for production (beside the current 0.x version in general)?
  • Is there a overview/documentation of the @ annotations somewhere?

Best regards
/ben

Entity id only been checked on current class or first subclass

If I have something like

class A extends BaseEntity {
   @Column({ index: true })
  public id: string = '';
}

class B extends A {
  ...
}

@Entity({ kind: 'c' })
class C extends B {
...
}

it throws an error (C) Entity must define an id column.

I think this is caused by only checking first subclass and not all possible subclasses, here:

const subClassTarget = Object.getPrototypeOf(target);
if (subClassTarget !== BaseEntity) {
const subClassEntityMeta = datastoreOrm.getEntityMeta(subClassTarget);
if (subClassEntityMeta) {
throw new DatastoreOrmDecoratorError(`(${(target as any).name}) Entity is subclassing (${subClassTarget.name}) which is already defined as an Entity.`);
}
const subClassColumns = datastoreOrm.getEntityColumns(subClassTarget);
for (const [column, entityColumn] of Object.entries(subClassColumns)) {
datastoreOrm.addColumn(target, column, entityColumn);
}
}

Firestore?

I know Google has Datastore and then what they call Firestore. I don't quite understand the difference, but is this library compatible with both?

Better documentation?

I found this library really cool, but it is lacking of API documentation, and hard to know the purpose of each API, e.g., the meaning of generateId, _id.

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.