Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(validator): add indexed as ignored const #151

Open
wants to merge 141 commits into
base: release/0.2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
0532a88
Corrected port on README.md examples to the default Bolt port of 7687
kerryboyko Oct 9, 2017
277dfe0
Merge branch 'master' of github.com:adam-cowley/neode
adam-cowley Nov 2, 2017
c689377
Use hasOwnProperty on Relationship::get() - fixes #4
adam-cowley Jan 1, 2018
1ecf228
0.1.11
adam-cowley Jan 1, 2018
8fe1a47
Create LICENSE
adam-cowley Jan 5, 2018
63b0483
Throw a validation error when properties passed to validator aren't a…
adam-cowley Jan 19, 2018
cc86e46
0.1.12
adam-cowley Jan 19, 2018
bdab560
Merge branch 'master' of github.com:adam-cowley/neode
adam-cowley Jan 19, 2018
ccae12b
Fixed assignment bugs on extending a model. Fixes #5, #6
adam-cowley May 21, 2018
d3e2bcc
0.1.13
adam-cowley May 21, 2018
233dcd3
Initial typings added
Jun 22, 2018
fa0088e
Added property type readonly which reads values from neo4j DB but nev…
Jun 22, 2018
9b191a5
Fix lint error on unexpected negation
Jun 22, 2018
8dc4401
Lint fix
Jun 22, 2018
72651c7
Added schema type
Jun 22, 2018
357fc2d
Added spatial properties
Jun 28, 2018
aca820b
Initial typings added
Jun 22, 2018
a299254
Merge branch 'master' into property_date
adam-cowley Jul 1, 2018
cf7660a
Merge pull request #11 from noumaans/property_date
adam-cowley Jul 1, 2018
b60c6bc
Fix for undefined when using instance.query()
Jun 29, 2018
cc163f5
FindWithinDistance query added which uses distance() to filter search
Jun 29, 2018
64a4e24
Bumped neo4j versions
adam-cowley Jul 1, 2018
0ee9e6d
0.1.14
adam-cowley Jul 1, 2018
a85f31d
Added filename filter to files loaded with withDirectory to only load…
adam-cowley Jul 13, 2018
d5eb75a
0.1.15
adam-cowley Jul 13, 2018
40ea1e9
Build
adam-cowley Jul 13, 2018
b2e3bde
0.1.16
adam-cowley Jul 13, 2018
2da57ee
Added additional driver configuration options
adam-cowley Jul 23, 2018
2fdd704
Merge branch 'release/0.2'
adam-cowley Sep 19, 2018
b8e9987
Patch Version
adam-cowley Sep 19, 2018
f138d97
Removed merge conflicts from typescript file
adam-cowley Sep 19, 2018
5e394f8
0.2.9
adam-cowley Sep 19, 2018
235d568
Fix `index` usage in schema
a-type Sep 22, 2018
3813f92
- Removed remaining merge conflicts in (fixes #26)
adam-cowley Sep 25, 2018
918dac5
0.2.10
adam-cowley Sep 25, 2018
6b8e1cc
Fixed relationship().to() bug in Builder
adam-cowley Sep 25, 2018
d11f838
Fix doc
bboure Sep 23, 2018
d5a10d5
Update package.json to have MIT License
johnsonjo4531 Oct 3, 2018
89980f1
Temporarily disabled Travis CI
adam-cowley Oct 24, 2018
d0b2d37
Merge branch 'master' of github.com:adam-cowley/neode
adam-cowley Oct 24, 2018
91ca58d
Fix https://github.com/adam-cowley/neode/issues/32
purplemana Sep 29, 2018
8944fbb
Fix https://github.com/adam-cowley/neode/issues/32
purplemana Sep 29, 2018
8765e1f
Return raw Joi error without wrapping it up.
SukantGujar Oct 23, 2018
dd698e5
Fix `map` return type.
SukantGujar Oct 23, 2018
3e0f9c4
Fix `Model.relationship` api `schema` param type.
SukantGujar Oct 23, 2018
656746d
Make `Neode.model` `schema` param optional.
SukantGujar Oct 23, 2018
a6a0421
Added validation for node(s) and relationship(s)
adam-cowley Feb 5, 2019
6c8c26d
Merge branch 'master' of github.com:adam-cowley/neode
adam-cowley Feb 5, 2019
8b33854
Fixed failing tests after merge with master
adam-cowley Feb 5, 2019
853ce68
0.2.11
adam-cowley Feb 5, 2019
32f404e
correctly cast disableLosslessIntegers from .env - fixes #44
adam-cowley Feb 5, 2019
6152d40
Added validation to node and relationship updates
adam-cowley Feb 6, 2019
ca5eeb6
0.2.12
adam-cowley Feb 6, 2019
9290c47
Fixed bug where same field cannot be included in 2 where clauses. Ad…
adam-cowley Feb 8, 2019
f6dcb11
Added test
adam-cowley Feb 8, 2019
c9f7020
0.2.13
adam-cowley Feb 8, 2019
bb97d6c
Add support for properties mutations
bboure Feb 24, 2019
e9e9a48
0.2.14
adam-cowley Mar 8, 2019
8b666d8
Implement Raw SET
bboure Mar 14, 2019
b2aefe4
:memo: Added many missing types in node properties
steve-nzr Mar 13, 2019
a66fa79
:memo: Added missing doc about strings
steve-nzr Mar 13, 2019
9b533f1
added toCollection method
adam-cowley Apr 23, 2019
454f0cd
0.2.15
adam-cowley Apr 23, 2019
f978655
Merge branch 'master' of github.com:adam-cowley/neode
adam-cowley Apr 23, 2019
5132027
Updated dependencies
adam-cowley Jun 11, 2019
ba755fe
0.2.16
adam-cowley Jun 11, 2019
f8aec9b
Fixed 'the request of a dependency is an expression' warning
mhoangvslev Apr 25, 2019
d4e7987
Allow nulls
adam-cowley Jul 20, 2019
c2da9ed
0.2.17
adam-cowley Jul 20, 2019
e4aa2ff
Removed console.log...sorry
adam-cowley Jul 20, 2019
b20fb99
0.2.18
adam-cowley Jul 20, 2019
b27b498
Fixed false boolean set bug, upgraded joi (Fixes #71)
adam-cowley Jul 30, 2019
a85fa51
0.2.19
adam-cowley Jul 30, 2019
e35e5f6
Merge branch 'master' of github.com:adam-cowley/neode
adam-cowley Jul 30, 2019
05eeed2
Rebuild
adam-cowley Jul 30, 2019
06aadad
0.2.20
adam-cowley Jul 30, 2019
ca0c12b
removed old joi dependency
adam-cowley Jul 30, 2019
628f378
0.2.21
adam-cowley Jul 30, 2019
4c799c6
Switch joi imports from to @hapi/joi
adam-cowley Jul 31, 2019
e60c6ab
0.3.0
adam-cowley Jul 31, 2019
86b7676
Convert integers to a Neo4j int
adam-cowley Aug 5, 2019
cefb165
0.3.1
adam-cowley Aug 5, 2019
9a21f04
Some clean up, bumped neo4j version
adam-cowley Aug 19, 2019
69309dc
0.3.2
adam-cowley Aug 19, 2019
3bf40ed
Fixed WriteSession method
guham Aug 7, 2019
61c8b1b
Added new build
guham Aug 7, 2019
0275880
add missing duration date type
jclappiway Aug 1, 2019
853380d
update node types
jclappiway Aug 2, 2019
6fcf529
update types
jclappiway Aug 6, 2019
86ad0ba
update types
jclappiway Aug 6, 2019
c15799b
Update index.d.ts
jclappiway Aug 27, 2019
6159079
Update Collection.js
jclappiway Aug 27, 2019
320452e
build
jclappiway Aug 27, 2019
2e186a4
Update index.d.ts
jclappiway Aug 29, 2019
82de2ea
Added missing config type in Neode constructor
guham Aug 9, 2019
4103867
fixed properties
0xflotus May 16, 2019
8900ab9
Merge branch 'master' of github.com:adam-cowley/neode
adam-cowley Sep 8, 2019
19774ac
Passing tests
adam-cowley Sep 8, 2019
c47f62a
0.3.3
adam-cowley Sep 8, 2019
3433f9c
Updated travis config
Oct 8, 2019
2fe77ee
Make collection iterable #76
Oct 8, 2019
61af8df
Fixed validator tests, fixes issue with #82 (#85)
adam-cowley Oct 8, 2019
ba6d940
Correct validation on updated properties - Closes #66 (#86)
adam-cowley Oct 8, 2019
3a42278
0.3.4
Oct 8, 2019
f25a7d6
Better error messages (#87)
adam-cowley Oct 13, 2019
720e035
Merge branch 'master' of github.com:adam-cowley/neode
Oct 13, 2019
d4080b3
0.3.5
Oct 13, 2019
0d82e5e
Removed fsevents from package.json
Oct 15, 2019
0739de6
convert {param} syntax to (#95)
am17torres Jan 6, 2020
4922db8
package-lock
adam-cowley Jan 6, 2020
3af2fa5
0.3.6
adam-cowley Jan 6, 2020
7d60d4d
0.3.7
adam-cowley Jan 6, 2020
5c509ac
Added fixes to Relationship type in index.d.ts (#96)
MSST Jan 29, 2020
b9a6147
Merge branch 'master' of github.com:adam-cowley/neode
adam-cowley Feb 5, 2020
3805093
4.0 ready
adam-cowley Feb 12, 2020
c959cb3
0.4.0
adam-cowley Feb 12, 2020
f6441c4
Dependency bum. Fixed types
adam-cowley Feb 27, 2020
a670409
Updated dependencies to latest version
adam-cowley Feb 27, 2020
20c0040
0.4.1
adam-cowley Feb 27, 2020
936408f
Get those tests running again
adam-cowley Feb 27, 2020
eaaa8e7
Fixed clashing of Node with Neo4j Driver's node
adam-cowley Feb 28, 2020
9c1fca9
0.4.2
adam-cowley Feb 28, 2020
4453ba3
Added cleanup of properties on node.update() and relationship.update()
adam-cowley Mar 13, 2020
37a33e2
0.4.3
adam-cowley Mar 13, 2020
45765dc
Updated readme, closes #101, 108
adam-cowley Apr 18, 2020
b5bc44f
Added string check to cleanValue on temporal type
adam-cowley May 18, 2020
de1e8f3
0.4.4
adam-cowley May 18, 2020
0905fca
Add node.detachFrom(other) (#121)
AbdullahAli Jun 5, 2020
68b0c75
0.4.5
adam-cowley Jun 5, 2020
f853284
Fixed multidb issues (closes #111), updated type defs (closes #119)
adam-cowley Jun 5, 2020
001f157
Fix #127 (#128)
gueno-dev Aug 24, 2020
9e87831
Fixed bug where null values aren't set in node.update. Closes #141 (…
adam-cowley Oct 5, 2020
3d33535
Use transaction functions in query builder
adam-cowley Jan 22, 2021
5b91360
0.4.6
adam-cowley Jan 22, 2021
8bc691a
0.4.7
adam-cowley Jan 22, 2021
6a8d0ff
Update index.d.ts (#146)
CodingByJerez Mar 23, 2021
1e85681
Update README.md (#147)
CodingByJerez Mar 23, 2021
feb6a61
Check index is created for schema #149
adam-cowley Apr 14, 2021
d52c962
Remove schema from tests
adam-cowley Apr 14, 2021
caed800
fix(validator): add indexed constant to ignore validation
4lessandrodev Apr 15, 2021
147a476
Merge pull request #1 from 4lessandrodev/fix/validator-indexed
4lessandrodev Apr 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"presets": ["env"]
}

"presets": [
"@babel/preset-env"
]
}
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ coverage/*
.env.example
.eslintrc
.gitignore
gulpfile.js
gulpfile.js
.travis.yml
TODO.md
27 changes: 19 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
enabled: false
language: node_js

jdk:
- oraclejdk8

env:
- NEO4J_VERSION="4.0.0"

before_install:
- wget dist.neo4j.org/neo4j-enterprise-$NEO4J_VERSION-unix.tar.gz
- tar -xzf neo4j-enterprise-$NEO4J_VERSION-unix.tar.gz
- neo4j-enterprise-$NEO4J_VERSION/bin/neo4j-admin set-initial-password TravisCI
- neo4j-enterprise-$NEO4J_VERSION/bin/neo4j start

branches:
only:
- master

node_js:
- "7"
- "6"
- "8"
- "12"

script:
- "npm run test"

services:
- neo4j

before_script:
- neo4j-admin set-initial-password TravisCI
67 changes: 40 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,20 @@ npm i --save dotenv

```
// .env
NEO4J_PROTOCOL=bolt
NEO4J_PROTOCOL=neo4j
NEO4J_HOST=localhost
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=neo4j
NEO4J_PORT=7687
NEO4J_DATABASE=neo4j
NEO4J_ENCRYPTION=ENCRYPTION_OFF
```

```javascript
// index.js
import Neode from 'neode';

const instance = new Neode.fromEnv();
const instance = Neode.fromEnv();
```

#### Additional Driver Config
Expand All @@ -76,7 +78,7 @@ NEO4J_DISABLE_LOSSLESS_INTEGERS=false

#### Loading `with` Models

You can use the `with()` method to load multipe models at once.
You can use the `with()` method to load multiple models at once.

```javascript
const neode = require('neode')
Expand Down Expand Up @@ -130,7 +132,7 @@ instance.model('Person', {
},
name: {
type: 'name',
indexed: true, // Creates an Index
index: true, // Creates an Index
},
age: 'number' // Simple schema definition of property : type
});
Expand All @@ -145,18 +147,18 @@ The following property types are supported:
- `int`
- `integer`
- `float`
- `uuid`
- `node`
- `nodes`
- `relationship`
- `relationships`
- Temporal
- `date`
- `time`
- `datetime`
- `localtime`
- `localdatetime`
- `duration`
- `uuid`
- `node`
- `nodes`
- `relationship`
- `relationships`
- Spatial
- `point`
- `distance`
Expand Down Expand Up @@ -195,12 +197,8 @@ Validation is provided by the [Joi](https://github.com/hapijs/joi/) library. Ce

| option | type | description | example |
| -- | -- | -- | -- |
| min | String | Date string or `now` to compare to the current date
| max | String
| greater
| less
| iso | Requires the string value to be in valid ISO 8601 date format.
| timestamp | Requires the value to be a timestamp - `unix` or `javascript`
| before | String | `Date`, date string or `"now"` to compare to the current date
| after | String | `Date`, date string or `"now"` to compare to the current date


##### Numbers (number, int, integer, float)
Expand Down Expand Up @@ -228,12 +226,12 @@ Validation is provided by the [Joi](https://github.com/hapijs/joi/) library. Ce
| creditCard | Boolean | Requires the number to be a credit card number (Using Luhn Algorithm).
| length | Number | Exact string length
| regex | Object | Regular expression rule | `{ pattern: /([A-Z]+)/, invert: true, name: 'myRule'}`
| replace | Object | Replace in value | `{ pattern: /(^[A-Z]+)/, replace: '-' }`
| replace | Object | Replace in value | `{ pattern: /(^[A-Z]+)/, replace: '-' }`
| alphanum | Boolean | Requires the string value to only contain a-z, A-Z, and 0-9.
| token | Boolean | Requires the string value to only contain a-z, A-Z, 0-9, and underscore _.
| email | Boolean/Object |
| ip | Boolean/Object |
| uri | Boolean/Object |
| email | Boolean/Object |
| ip | Boolean/Object |
| uri | Boolean/Object |
| guid | Boolean
| hex | Boolean/Object
| base64 | Boolean/Object
Expand All @@ -250,11 +248,11 @@ Validation is provided by the [Joi](https://github.com/hapijs/joi/) library. Ce
Relationships can be created in the schema or defined retrospectively.

```javascript
instance.model(label).relationship(type, relationship, direction, label, schema);
instance.model(label).relationship(type, relationship, direction, target, schema, eager, cascade, node_alias);
```

```javascript
instance.model('Person').relationship('knows', 'KNOWS', 'out', 'Person', {
instance.model('Person').relationship('knows', 'relationship', 'KNOWS', 'out', 'Person', {
since: {
type: 'number',
required: true,
Expand Down Expand Up @@ -324,24 +322,24 @@ instance.cypher(query, params)
```

```javascript
instance.cypher('MATCH (p:Person {name: {name}}) RETURN p', {name: "Adam"})
instance.cypher('MATCH (p:Person {name: $name}) RETURN p', {name: "Adam"})
.then(res => {
console.log(res.records.length);
})
```

### Running a Batch
Batch queries run within their own transaction. Transactions can be sent as either a string or an object containing `query` and `param` propertes.
Batch queries run within their own transaction. Transactions can be sent as either a string or an object containing `query` and `param` properties.

```
instance.batch(queries)
```

```javascript
instance.batch([
{query: 'CREATE (p:Person {name: {name}}) RETURN p', params: {name: "Adam"}},
{query: 'CREATE (p:Person {name: {name}}) RETURN p', params: {name: "Joe"}},
{query: 'MATCH (first:Person {name: {first_name}}), (second:Person {name:{second_name}}) CREATE (first)-[:KNOWS]->(second)', params: {name: "Joe"}}
{query: 'CREATE (p:Person {name: $name}) RETURN p', params: {name: "Adam"}},
{query: 'CREATE (p:Person {name: $name}) RETURN p', params: {name: "Joe"}},
{query: 'MATCH (first:Person {name: $first_name}), (second:Person {name: $second_name}) CREATE (first)-[:KNOWS]->(second)', params: {name: "Joe"}}
])
.then(res => {
console.log(res.records.length);
Expand Down Expand Up @@ -479,13 +477,28 @@ Promise.all([
.then(([adam, joe]) => {
adam.relateTo(joe, 'knows', {since: 2010})
.then(res => {
console.log(rel.from().get('name'), ' has known ', rel.to().get('name'), 'since', rel.get('since')); // Adam has known Joe since 2010
console.log(res.startNode().get('name'), ' has known ', res.endNode().get('name'), 'since', res.get('since')); // Adam has known Joe since 2010
});
});
```

**Note:** when creating a relationship defined as `in` (`DIRECTION_IN`), from `from()` and `to()` properties will be inversed regardless of which model the relationship is created by.

### Detaching two nodes
You can detach two nodes by calling the `detachFrom()` method.

```javascript
model.detachFrom(other)
```
```javascript
Promise.all([
instance.create('Person', {name: 'Adam'}),
instance.create('Person', {name: 'Joe'})
])
.then(([adam, joe]) => {
adam.detachFrom(joe) // Adam does not know Joe
});

### Deleting a node
You can delete a Node instance directly by calling the `delete()` method.

Expand Down
14 changes: 14 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# TODO
- Routing policies and countries for CC
- Relationships
- Relationship Constraints
- Delete dependencies when deleting a node beyond the first degree
- Schema
- Composite indexes
- Query Builder
- More where clauses
- CREATE
- SET
- DELETE
- Match Relationship
- Match path
Loading