0.1.2 • Published 3 years ago

@neode/beta v0.1.2

Weekly downloads
13
License
ISC
Repository
-
Last release
3 years ago

= NeodeGM

Experiments in how neode could become more object oriented.

== Example

  • Create your model as a class:

source,typescript

// Create @Node({ labels: 'Person', 'Actor' }) export default class Person { @Uuid() @Primary() @Unique() id: string;

@String()
name: string;

getId() {
    return this.id
}

getName() {
    return this.name
}

}

  • Write some code:

source,typescript

// Connect from .env const neode = neode.fromEnv()

// TOOD: Open a transaction neode.openTransaction()

// Create an object const adam = new Person("92702e6b-4d39-4ad2-a4ad-cc3923496090", 'Adam')

// Save it neode.save(adam)

// Retrieve it

const found = neode.find(Person, "92702e6b-4d39-4ad2-a4ad-cc3923496090")

== Repository Pattern


// Use decorator to register the PersonRepository as using the Person node @RepositoryDecorator(Person)

export default class PersonRepository extends Repository {}

  • Create an instance of the repository and use it

source,typescriptw

const repo = new PersonRepository()

const adam = repo.find("92702e6b-4d39-4ad2-a4ad-cc3923496090")

== Transaction Management (TODO)

  • Call the main repo to open a transaction - this will return a transaction based instance of neode. The save, create, (etc) methods will run everything in the context of a single transaction.
  • Otherwise the base class will create a new transaction every time.

source,typescript

neode.inWriteTransaction() .then(async inTx => { const adam = new Person("92702e6b-4d39-4ad2-a4ad-cc3923496090", 'Adam') await inTx.save(adam)

    const arthur = new Person("92702e6b-4d39-4ad2-a4ad-cc3923496090", 'Arthur')
    await inTx.save(arthur)

    await inTx.commit()
})

== Annotations (TODO)

  • @NeodeRepository

=== Entities

  • @NodeEntity
  • @RelationshipEntity

=== Property Types

  • @String
  • @Uuid
  • @Int
  • @Float
  • @Number
  • @Property

=== Relationships

  • @OneToOne
  • @OneToMany

== Writing

  • @Default
  • @OnCreateSet
  • @OnMatchSet

=== Schema

  • @Primary
  • @Unique

== Other TODO's

  • neode.installSchema()