Example blocks
Example blocks should have a background colour in the docs theme
Example 1
A short example
Lorem Ipsunm
Some text follows the example
Lorem Ipsunm
And some more text here
Example 2
A longer example
Let’s assume there exists a procedure called myProc
.
This procedure gives the result A
and B
for a user with EXECUTE PROCEDURE
privilege and A
, B
and C
for a user with EXECUTE BOOSTED PROCEDURE
privilege.
Now, let’s adapt the privileges in examples 1 to 4 to apply to this procedure and show what is returned.
With the privileges from example 1, granted EXECUTE PROCEDURE *
and denied EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
and B
.
With the privileges from example 2, granted EXECUTE BOOSTED PROCEDURE *
and denied EXECUTE PROCEDURE myProc
, execution of the myProc
procedure is not allowed.
With the privileges from example 3, granted EXECUTE BOOSTED PROCEDURE *
and denied EXECUTE BOOSTED PROCEDURE myProc
, execution of the myProc
procedure is not allowed.
With the privileges from example 4, granted EXECUTE PROCEDURE myProc
and EXECUTE BOOSTED PROCEDURE *
and denied EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
and B
.
For comparison, when only granted EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
, B
and C
, without needing to be granted the EXECUTE PROCEDURE myProc
privilege.
A line of text after the longer example
Run Cypher administrative commands from Cypher Shell on a cluster
For the following examples consider a cluster environment formed by 5 members, 3 Core servers, and 2 Read Replicas:
neo4j@neo4j> CALL dbms.cluster.overview();
+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | id | addresses | databases | groups | +------------------------------------------------------------------------------------------------------------------------------------------------------------+ | "8c...3d" | ["bolt://localhost:7683", "http://localhost:7473", "https://localhost:7483"] | {neo4j: "FOLLOWER", system: "FOLLOWER"} | [] | | "8f...28" | ["bolt://localhost:7681", "http://localhost:7471", "https://localhost:7481"] | {neo4j: "LEADER", system: "LEADER"} | [] | | "e0...4d" | ["bolt://localhost:7684", "http://localhost:7474", "https://localhost:7484"] | {neo4j: "READ_REPLICA", system: "READ_REPLICA"} | [] | | "1a...64" | ["bolt://localhost:7682", "http://localhost:7472", "https://localhost:7482"] | {neo4j: "FOLLOWER", system: "FOLLOWER"} | [] | | "59...87" | ["bolt://localhost:7685", "http://localhost:7475", "https://localhost:7485"] | {neo4j: "READ_REPLICA", system: "READ_REPLICA"} | [] | +------------------------------------------------------------------------------------------------------------------------------------------------------------+ 5 rows available after 5 ms, consumed after another 0 ms
The leader is currently the instance exposing port 7681
for the bolt
protocol, and 7471/7481
for the http/https
protocol.
Administrators can connect and execute Cypher commands in the following ways:
bolt://
scheme to connect to the Leader:$ bin/cypher-shell -a bolt://localhost:7681 -d system -u neo4j -p neo4j1
Connected to Neo4j 4.0.0 at bolt://localhost:7681 as user neo4j. Type :help for a list of available commands or :exit to exit the shell. Note that Cypher queries must end with a semicolon.
neo4j@system> SHOW DATABASES;
+-------------------------------+ | name | status | default | +-------------------------------+ | "neo4j" | "online" | TRUE | | "system" | "online" | FALSE | +-------------------------------+ 2 rows available after 34 ms, consumed after another 0 ms
neo4j@system> CREATE DATABASE data001;
0 rows available after 378 ms, consumed after another 12 ms Added 1 nodes, Set 4 properties, Added 1 labels neo4j@system> SHOW DATABASES; +--------------------------------+ | name | status | default | +--------------------------------+ | "neo4j" | "online" | TRUE | | "system" | "online" | FALSE | | "data001" | "online" | FALSE | +--------------------------------+ 3 rows available after 2 ms, consumed after another 1 ms
Source Blocks with Headers
Copy Button
The Copy To Clipboard button will appear on all code blocks:
[source,adoc]
Copy me!
Unless you add role=nocopy
:
[source,adoc,role=nocopy]
Don't copy me!
Play In Browser
Source blocks with a type of cypher will have a deeplink to run the query in Neo4j Browser
MATCH (n) RETURN count(n)
Unless you add role=noplay
role=noplay
[source,adoc,role=noplay]
MATCH (n) RETURN count(n)
Reference lines
You can add number bubbles to reference specific lines by appending <n>
to a line. It is advised to put them behind a line comment for the language the code is in.
require 'sinatra' (1)
get '/hi' do (2) (3)
"Hello World!"
end
1 | Library import |
2 | URL mapping |
3 | Response block |
line of code (1)
line of code (2)
line of code (3)
line of code (4)
1 | A callout behind a line comment for C-style languages. |
2 | A callout behind a line comment for Ruby, Python, Perl, etc. |
3 | A callout behind a line comment for Clojure. |
4 | A callout behind a line comment for XML or SGML languages like HTML. |
Expand code block
Code blocks longer than 15 lines (+5 of tolerance) are collapsed, unless you add role=nocollapse
[source,js]
...
[source,js,role=nocollapse]
...
// Collapse/Expand long blocks
var codeMaxLines = 15 // lines
var codeTolerance = 5 // lines
var codeLineHeight = parseFloat(window.getComputedStyle(
document.getElementsByClassName('highlight')[0], null)
.getPropertyValue('line-height'))
var codeMaxHeight = codeLineHeight*codeMaxLines
var maskImage = 'linear-gradient(to bottom, black 0px, transparent ' +
(codeMaxHeight + 100) + 'px)'
var codeBlockLinesNum = function (code) {
var paddingTop = parseFloat(window.getComputedStyle(code, null).getPropertyValue('padding-top'))
var paddingBottom = parseFloat(window.getComputedStyle(code, null).getPropertyValue('padding-bottom'))
var height = code.clientHeight-paddingTop-paddingBottom;
var lines = Math.ceil(height / codeLineHeight)
var hiddenLines = Math.ceil(lines - codeMaxLines)
return hiddenLines
}
var expandCollapseBlock = function (e) {
e.preventDefault()
var showMore = e.target
var pre = showMore.parentNode
var code = pre.querySelector('code')
if (pre.style.overflow === 'hidden') {
window.sessionStorage.setItem('scrollpos', window.scrollY)
pre.style.maxHeight = pre.scrollHeight + 'px'
pre.style.overflow = 'visible'
code.style.webkitMaskImage = ''
code.style.maskImage = ''
showMore.innerHTML = '↑' // show less
} else {
// Scoll back to where you where before expanding
var scrollpos = window.sessionStorage.getItem('scrollpos')
if (scrollpos) {
window.scrollTo({
top: scrollpos,
behavior: 'auto',
})
}
window.sessionStorage.removeItem('scrollpos')
var hiddenLines = codeBlockLinesNum(code)
pre.style.maxHeight = codeMaxHeight + 'px'
pre.style.overflow = 'hidden'
code.style.webkitMaskImage = maskImage
code.style.maskImage = maskImage
showMore.innerHTML = '↓ View all (' + hiddenLines + ' lines more) ↓'
}
}
// Collapse long blocks on load
var collapseCodeBlock = function (pre) {
var dotContent = pre.parentNode
var listingBlock = dotContent.parentNode
var code = pre.querySelector('code')
if (!listingBlock.classList.contains('nocollapse') &&
pre.offsetHeight > (codeMaxLines+codeTolerance)*codeLineHeight) {
pre.style.maxHeight = codeMaxHeight + 'px'
pre.style.overflow = 'hidden'
code.style.webkitMaskImage = maskImage
code.style.maskImage = maskImage
var hiddenLines = codeBlockLinesNum(code)
var showMore = createElement('a', 'show-more')
showMore.innerHTML = '↓ View all (' + hiddenLines + ' lines more) ↓'
showMore.addEventListener('click', expandCollapseBlock)
pre.appendChild(showMore)
}
}
// Apply collapseCodeBlock
document.querySelectorAll('.highlight')
.forEach(collapseCodeBlock)
Let’s assume there exists a procedure called myProc
.
This procedure gives the result A
and B
for a user with EXECUTE PROCEDURE
privilege and A
, B
and C
for a user with EXECUTE BOOSTED PROCEDURE
privilege.
Now, let’s adapt the privileges in examples 1 to 4 to apply to this procedure and show what is returned.
With the privileges from example 1, granted EXECUTE PROCEDURE *
and denied EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
and B
.
With the privileges from example 2, granted EXECUTE BOOSTED PROCEDURE *
and denied EXECUTE PROCEDURE myProc
, execution of the myProc
procedure is not allowed.
With the privileges from example 3, granted EXECUTE BOOSTED PROCEDURE *
and denied EXECUTE BOOSTED PROCEDURE myProc
, execution of the myProc
procedure is not allowed.
With the privileges from example 4, granted EXECUTE PROCEDURE myProc
and EXECUTE BOOSTED PROCEDURE *
and denied EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
and B
.
For comparison, when only granted EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
, B
and C
, without needing to be granted the EXECUTE PROCEDURE myProc
privilege.
Let’s assume there exists a procedure called myProc
.
This procedure gives the result A
and B
for a user with EXECUTE PROCEDURE
privilege and A
, B
and C
for a user with EXECUTE BOOSTED PROCEDURE
privilege.
Now, let’s adapt the privileges in examples 1 to 4 to apply to this procedure and show what is returned.
With the privileges from example 1, granted EXECUTE PROCEDURE *
and denied EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
and B
.
With the privileges from example 2, granted EXECUTE BOOSTED PROCEDURE *
and denied EXECUTE PROCEDURE myProc
, execution of the myProc
procedure is not allowed.
With the privileges from example 3, granted EXECUTE BOOSTED PROCEDURE *
and denied EXECUTE BOOSTED PROCEDURE myProc
, execution of the myProc
procedure is not allowed.
With the privileges from example 4, granted EXECUTE PROCEDURE myProc
and EXECUTE BOOSTED PROCEDURE *
and denied EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
and B
.
For comparison, when only granted EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
, B
and C
, without needing to be granted the EXECUTE PROCEDURE myProc
privilege.
// Collapse/Expand long blocks
var codeBlockMaxHeight = 300 // px
var styleMaskImage = 'linear-gradient(to bottom, black 0px, transparent ' + (codeBlockMaxHeight+100) + 'px)'
var expandCollapseBlock = function (e) {
e.preventDefault();
var showMore = e.target
var pre = showMore.parentNode
var codeBlock = pre.querySelector('code')
if (pre.st.style.webkitMaskImage = styleMaskImage
codeBlock.style.maskImage = styleMaskImage
showMore.innerHTML = '↓' // show more
//codeBlock.scrollIntoView({behavior: 'smooth'})
}
}
if (pre.st.style.webkitMaskImage = styleMaskImage
codeBlock.style.maskImage = styleMaskImage
showMore.innerHTML = '↓' // show more
//codeBlock.scrollIntoView({behavior: 'smooth'})
}
}
With the privileges from example 4, granted EXECUTE PROCEDURE myProc
and EXECUTE BOOSTED PROCEDURE *
and denied EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
and B
.
For comparison, when only granted EXECUTE BOOSTED PROCEDURE myProc
, the myProc
procedure returns the result A
, B
and C
, without needing to be granted the EXECUTE PROCEDURE myProc
privilege.
Was this page helpful?