0.2.19 • Published 7 years ago

vineyard-ground v0.2.19

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

Vineyard Ground

SQL ORM for Node.js. Uses Sequelize and Vineyard Schema.

Features

  • Uses POD (Plain Old Data) objects.
  • Schema can be defined entirely in JSON.
  • Comprehensive understanding of table relationships (something most JavaScript ORMs lack.)
  • Chainable query API.
  • Automatic identity resolution. (Functions requiring an entity identifier can be passed either an object or scalar identity value.)

API

Collection

create(seed): Promise<T>

Creates a new entity and saves it to the database. Returns a copy of the new entity.

update(seed, changes): Promise<T>

Updates a record.

seed can be either an id or a property with an id.

changes is a dictionary of property key/value pairs to be changed.

all(): Query<T>

Returns a query containing all items in that collection.

filter(options): Query<T>

Returns a query containing all items in the collection that match the key/value pairs in options

first(options?): Query<T>

Returns the first item in the collection, optionally filtered by key/value pairs.

get(identity): Query<T>

Returns a single item that matches the provided id.

Query

Queries are chainable, allowing for processes like:

model.Character
  .filter({health: 20})
  .expand('inventory')
  .expand('race')
  .select(['id', 'inventory', 'race.name'])

Since queries are chainable, they are not actually executed until either the exec or then method is called.

then(handler: any): Promise<any>

Executes the query and attaches a handler to the promise resolution.

exec(): Promise<any>

Executes the query. This is only needed when then is not called.

filter(options): Query<T>

Returns a query containing all items in the current query that match the key/value pairs in options

first(options?): Query<T>

Returns the first item in the current query, optionally filtered by key/value pairs.

expand(path: string): Query<T2>

Causes entities returned by the query to have the specified related entities expanded instead of being returned as scalar identity values.

For example, while this

model.Employee.first()

would return

{
  id: 23103013,
  name: "Bob",
  company: 31414515
}

adding an expansion

model.Employee.first().expand('company')

would return

{
  id: 23103013,
  name: "Bob",
  company: {
    id: 31414515,
    name: "Bob's Burger Joint"
  }
}
0.2.19

7 years ago

0.2.18

7 years ago

0.2.17

7 years ago

0.2.16

7 years ago

0.2.15

7 years ago

0.2.14

7 years ago

0.2.13

7 years ago

0.2.12

7 years ago

0.2.11

7 years ago

0.2.10

7 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.1.84

9 years ago

0.1.83

9 years ago

0.1.82

9 years ago

0.1.81

9 years ago

0.1.80

9 years ago

0.1.79

9 years ago

0.1.78

9 years ago

0.1.77

9 years ago

0.1.76

9 years ago

0.1.75

9 years ago

0.1.74

9 years ago

0.1.73

9 years ago

0.1.72

9 years ago

0.1.71

9 years ago

0.1.70

9 years ago

0.1.69

9 years ago

0.1.68

9 years ago

0.1.67

9 years ago

0.1.66

9 years ago

0.1.65

9 years ago

0.1.64

9 years ago

0.1.63

10 years ago

0.1.62

10 years ago

0.1.61

10 years ago

0.1.60

10 years ago

0.1.59

10 years ago

0.1.58

10 years ago

0.1.57

10 years ago

0.1.56

10 years ago

0.1.55

10 years ago

0.1.54

10 years ago

0.1.53

10 years ago

0.1.52

10 years ago

0.1.51

10 years ago

0.1.50

10 years ago

0.1.49

10 years ago

0.1.48

10 years ago

0.1.47

10 years ago

0.1.46

10 years ago

0.1.45

10 years ago

0.1.44

10 years ago

0.1.43

10 years ago

0.1.42

10 years ago

0.1.41

10 years ago

0.1.40

10 years ago

0.1.39

10 years ago

0.1.38

10 years ago

0.1.37

10 years ago

0.1.36

10 years ago

0.1.35

10 years ago

0.1.34

10 years ago

0.1.33

10 years ago

0.1.32

10 years ago

0.1.31

10 years ago

0.1.30

10 years ago

0.1.29

10 years ago

0.1.28

10 years ago

0.1.27

10 years ago

0.1.26

10 years ago

0.1.25

10 years ago

0.1.24

10 years ago

0.1.23

10 years ago

0.1.22

10 years ago

0.1.21

10 years ago

0.1.20

10 years ago

0.1.19

10 years ago

0.1.18

10 years ago

0.1.17

10 years ago

0.1.16

10 years ago

0.1.15

10 years ago

0.1.14

10 years ago

0.1.13

10 years ago

0.1.12

10 years ago

0.1.11

10 years ago

0.1.10

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago