-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Here are some examples on how to use datalink | ||
|
||
##Creating datalink values | ||
|
||
You can create datalink values from URLs by using `dlvalue()` function. | ||
|
||
select dlvalue('http://www.github.io/'); | ||
dlvalue | ||
---------------------------------- | ||
{"url": "http://www.github.io/"} | ||
(1 row) | ||
|
||
URLs are checked for syntax and wrong ones throw errors. | ||
|
||
postgres=# select dlvalue('foo bar'); | ||
ERROR: invalid input syntax for type uri at or near " bar" | ||
CONTEXT: PL/pgSQL function dlvalue(text,datalink.dl_linktype,text) line 15 at assignment | ||
|
||
URLs are normalized before they are converted to datalinks. | ||
|
||
select dlvalue('http://www.github.io/a/b/c/d/../../e'); | ||
dlvalue | ||
--------------------------------------- | ||
{"url": "http://www.github.io/a/b/e"} | ||
(1 row) | ||
|
||
Use `dlurlcompleteonly()` function to convert a datalink back to URL. | ||
|
||
select dlurlcompleteonly(dlvalue('http://www.github.io/a/b/c/d/../../e')); | ||
dlurlcompleteonly | ||
---------------------------- | ||
http://www.github.io/a/b/e | ||
(1 row) | ||
|
||
You can also use dlvalue() with absolute paths for file links. | ||
|
||
select dlvalue('/var/www/datalink/index.html'); | ||
dlvalue | ||
------------------------------------------------ | ||
{"url": "file:///var/www/datalink/index.html"} | ||
(1 row) | ||
|
||
Use `dlurlpatheonly()` function to get file path from a datalink. | ||
|
||
select dlurlpathonly(dlvalue('/var/www/datalink/index.html')); | ||
dlurlpathonly | ||
------------------------------ | ||
/var/www/datalink/index.html | ||
(1 row) | ||
|