Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit c3f93cc

Browse files
authored
feat(belongsToMany): support multiple relationships between same objects (#22)
* feat(belongsToMany): support multiple relationships between same objects
1 parent 047e32d commit c3f93cc

File tree

3 files changed

+1
-27
lines changed

3 files changed

+1
-27
lines changed

lib/model/saveAll.belongsToMany.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const debug = require('debug')('requelize:model:saveAll')
2-
const generateJoinId = require('./util/generateJoinId')
32

43
function baseSaveAll (Model, inst, requelize, key, join, RelModel, subTree, subInst_) {
54
debug(`saving belongsToMany ${Model._name}:${key} -> ${RelModel._name}`)
@@ -8,9 +7,7 @@ function baseSaveAll (Model, inst, requelize, key, join, RelModel, subTree, subI
87
return subInst
98
.then(subInst => subInst.saveAll(subTree))
109
.then((subInst) => {
11-
const joinId = generateJoinId(Model, RelModel, inst, subInst)
1210
const joinRel = new join.JoinModel({
13-
id: joinId,
1411
[Model._name]: inst[Model._options.primaryKey],
1512
[RelModel._name]: subInst[RelModel._options.primaryKey]
1613
})
@@ -33,7 +30,6 @@ function saveThrough (Model, inst, requelize, key, join, RelModel, subTree, subI
3330

3431
return subInst.document.saveAll(subTree)
3532
.then(() => {
36-
joinRel.id = generateJoinId(Model, RelModel, inst, subInst.document)
3733
joinRel._data[Model._name] = inst[Model._options.primaryKey]
3834
joinRel._data[RelModel._name] = subInst.document[RelModel._options.primaryKey]
3935

lib/model/util/generateJoinId.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "requelize",
3-
"version": "0.8.1",
3+
"version": "0.9.0",
44
"description": "RethinkDB ORM",
55
"main": "index.js",
66
"repository": "https://github.com/buckless/requelize.git",

0 commit comments

Comments
 (0)