Skip to content

Commit

Permalink
Rename LastInsertRecordID to LastInsertKey
Browse files Browse the repository at this point in the history
  • Loading branch information
asdine committed Oct 19, 2019
1 parent e306d7f commit f64277e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 2 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ func readIndexOptions(tx *Tx, indexName string) (*indexOptions, error) {
return &idxopts, nil
}

// Index of a table field. Contains information about
// the index configuration and provides methods to manipulate the index.
type Index struct {
index.Index

Expand Down
9 changes: 6 additions & 3 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Out of the box, Genji provides three implementations: BoltDB, Badger and in-memo
See the engine package documentation for more details.
Field, Record, and Stream
Field, Record, Table and Stream
Genji defines its own semantic to describe data.
Data stored in Genji being schemaless, the usual SQL triplet "column", "row", "table" wasn't chosen
Expand All @@ -22,15 +22,18 @@ is to map structures and maps to tables, though it's not limited to that.
That's why the triplet "field", "record" and "table" was chosen.
A field is a piece of information that has a type, content, and a name. It is managed by the field package, which provides helpers
to create and manipulate them. The field is equivalent to the SQL column, though it might contain nested fields in the future.
A field is a piece of information that has a type, content, and a name.
The field is equivalent to the SQL column, though it might contain nested fields in the future.
A record is a group of fields. It is an interface that can be implemented manually or by using Genji's code generation.
This is equivalent to the SQL row. It is managed by the record package, which also provides ways to encode and decode records.
A table is an abstraction on top of K-V stores that can read and write records.
This is equivalent to the SQL table.
A stream can read data from a table, record by record, and apply transformations, filter them, etc.
See the record package for more information.
These are the basic building blocks of the Genji database.
SQL support
Expand Down
4 changes: 2 additions & 2 deletions insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (stmt insertStmt) insertRecords(t *Table, stack evalStack) (Result, error)
r = &fb
}

res.lastInsertRecordID, err = t.Insert(r)
res.lastInsertKey, err = t.Insert(r)
if err != nil {
return res, err
}
Expand Down Expand Up @@ -442,7 +442,7 @@ func (stmt insertStmt) insertValues(t *Table, stack evalStack) (Result, error) {
})
}

res.lastInsertRecordID, err = t.Insert(&fb)
res.lastInsertKey, err = t.Insert(&fb)
if err != nil {
return res, err
}
Expand Down
16 changes: 8 additions & 8 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,23 @@ type statement interface {
// Result of a query.
type Result struct {
record.Stream
rowsAffected driver.RowsAffected
lastInsertRecordID []byte
tx *Tx
closed bool
rowsAffected driver.RowsAffected
lastInsertKey []byte
tx *Tx
closed bool
}

// LastInsertId is not supported and returns an error.
// Use LastInsertRecordID instead.
// Use LastInsertKey instead.
func (r Result) LastInsertId() (int64, error) {
return r.rowsAffected.LastInsertId()
}

// LastInsertRecordID returns the database's auto-generated key
// LastInsertKey returns the database's auto-generated key
// after, for example, an INSERT into a table with primary
// key.
func (r Result) LastInsertRecordID() ([]byte, error) {
return r.lastInsertRecordID, nil
func (r Result) LastInsertKey() ([]byte, error) {
return r.lastInsertKey, nil
}

// RowsAffected returns the number of rows affected by the
Expand Down

0 comments on commit f64277e

Please sign in to comment.