-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return now supports an additional options parameter that contains a `distinct` flag. Setting it to true will cause the return clause to only return unique rows. In addition, the `returnDistinct` method was added to the query interface as a shortcut to `return(..., { distinct: true }). fix #90
- Loading branch information
Showing
4 changed files
with
28 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import { Many } from 'lodash'; | ||
import { Term, TermListClause } from './term-list-clause'; | ||
|
||
export interface ReturnOptions { | ||
distinct?: boolean; | ||
} | ||
|
||
export class Return extends TermListClause { | ||
/** | ||
* Creates a return clause | ||
* @param {string|object|array<string|object>|} terms [description] | ||
*/ | ||
constructor(terms: Many<Term>) { | ||
constructor(terms: Many<Term>, protected options: ReturnOptions = {}) { | ||
super(terms); | ||
} | ||
|
||
build() { | ||
return `RETURN ${super.build()}`; | ||
const distinct = this.options.distinct ? ' DISTINCT' : ''; | ||
return `RETURN${distinct} ${super.build()}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters