Skip to content

ormjs: Edge collection modelling #4

@OKNoah

Description

@OKNoah

Hi, I'd like to work a bit on this package. I've forked it at https://github.com/OKNoah/ormjs.

I'm pretty new to ArangoDB.

I'd like to try add support for modelling edge collections. I believe this is done by var actsIn = db._createEdgeCollection("actsIn"); in the javascript driver, as seen here: https://github.com/arangodb/Cookbook/blob/master/recipes/Graph/ExampleActorsAndMovies.md

I'm just thinking of the syntax now. Open to suggestions. Perhaps like this.

import Model, { Edge } from './db'

/* A User lives at an Address */
export default class LivesAt extends Edge {
  static schema = {
    created: Date
  }
}

export default class User extends Model {
  static schema = {
    name: String,
    created: Date
  }
}

export default class Address extends Model {
  static schema = {
    street: String,
    city: String
  }
}

const user = await User.add({
  name: 'Will',
  created: Date()
})

const address = await Address.add({
  city: 'Bel Air'
})

const relationship = await LivesAt.add(user, address)

user.save()
address.save()
relationship.save()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions