fauna-shell
Advanced tools
Comparing version 0.0.11 to 0.1.0
{ | ||
"name": "fauna-shell", | ||
"description": "faunadb shell", | ||
"version": "0.0.11", | ||
"version": "0.1.0", | ||
"author": "Alvaro Videla", | ||
@@ -6,0 +6,0 @@ "bin": { |
@@ -138,3 +138,3 @@ fauna-shell | ||
```javascript | ||
faunadb> query(CreateClass({ name: "posts" })) | ||
faunadb> CreateClass({ name: "posts" }) | ||
faunadb> | ||
@@ -150,4 +150,3 @@ { ref: Ref(id=posts, class=Ref(id=classes)), | ||
```javascript | ||
faunadb> query( | ||
CreateIndex( | ||
faunadb> CreateIndex( | ||
{ | ||
@@ -157,3 +156,3 @@ name: "posts_by_title", | ||
terms: [{ field: ["data", "title"] }] | ||
})) | ||
}) | ||
faunadb> | ||
@@ -172,6 +171,5 @@ { ref: Ref(id=posts_by_title, class=Ref(id=indexes)), | ||
```javascript | ||
faunadb> query( | ||
Create( | ||
faunadb> Create( | ||
Class("posts"), | ||
{ data: { title: "What I had for breakfast .." } })) | ||
{ data: { title: "What I had for breakfast .." } }) | ||
faunadb> | ||
@@ -186,4 +184,3 @@ { ref: Ref(id=200221588659896832, class=Ref(id=posts, class=Ref(id=classes))), | ||
```javascript | ||
faunadb> query( | ||
Map( | ||
faunadb> Map( | ||
[ | ||
@@ -198,3 +195,3 @@ "My cat and other marvels", | ||
)) | ||
)) | ||
) | ||
faunadb> | ||
@@ -215,3 +212,3 @@ [ { ref: Ref(id=200221673472919040, class=Ref(id=posts, class=Ref(id=classes))), | ||
```javascript | ||
faunadb> query(Get(Ref("classes/posts/200221673471869440"))) | ||
faunadb> Get(Ref("classes/posts/200221673471869440")) | ||
faunadb> | ||
@@ -226,6 +223,5 @@ { ref: Ref(id=200221673471869440, class=Ref(id=posts, class=Ref(id=classes))), | ||
```javascript | ||
faunadb> query( | ||
Update( | ||
faunadb> Update( | ||
Ref("classes/posts/200221673472919040"), | ||
{ data: { tags: ["pet", "cute"] } })) | ||
{ data: { tags: ["pet", "cute"] } }) | ||
faunadb> | ||
@@ -240,6 +236,5 @@ { ref: Ref(id=200221673472919040, class=Ref(id=posts, class=Ref(id=classes))), | ||
```javascript | ||
faunadb> query( | ||
Replace( | ||
faunadb> Replace( | ||
Ref("classes/posts/200221673472919040"), | ||
{ data: { title: "My dog and other marvels" } })) | ||
{ data: { title: "My dog and other marvels" } }) | ||
{ ref: Ref(id=200221673472919040, class=Ref(id=posts, class=Ref(id=classes))), | ||
@@ -255,3 +250,3 @@ ts: 1527205345816901, | ||
```javascript | ||
faunadb> query(Delete(Ref("classes/posts/200221673471869440"))) | ||
faunadb> Delete(Ref("classes/posts/200221673471869440")) | ||
faunadb> | ||
@@ -266,3 +261,3 @@ { ref: Ref(id=200221673471869440, class=Ref(id=posts, class=Ref(id=classes))), | ||
```javascript | ||
faunadb> query(Get(Ref("classes/posts/200221673471869440"))) | ||
faunadb> Get(Ref("classes/posts/200221673471869440")) | ||
faunadb> | ||
@@ -396,3 +391,3 @@ Error: instance not found | ||
_See code: [src/commands/add-endpoint.js](https://github.com/fauna/fauna-shell/blob/v0.0.11/src/commands/add-endpoint.js)_ | ||
_See code: [src/commands/add-endpoint.js](https://github.com/fauna/fauna-shell/blob/v0.1.0/src/commands/add-endpoint.js)_ | ||
@@ -418,3 +413,3 @@ ## `fauna create-database DBNAME` | ||
_See code: [src/commands/create-database.js](https://github.com/fauna/fauna-shell/blob/v0.0.11/src/commands/create-database.js)_ | ||
_See code: [src/commands/create-database.js](https://github.com/fauna/fauna-shell/blob/v0.1.0/src/commands/create-database.js)_ | ||
@@ -441,3 +436,3 @@ ## `fauna create-key DBNAME [ROLE]` | ||
_See code: [src/commands/create-key.js](https://github.com/fauna/fauna-shell/blob/v0.0.11/src/commands/create-key.js)_ | ||
_See code: [src/commands/create-key.js](https://github.com/fauna/fauna-shell/blob/v0.1.0/src/commands/create-key.js)_ | ||
@@ -463,3 +458,3 @@ ## `fauna default-endpoint ENDPOINT_ALIAS` | ||
_See code: [src/commands/default-endpoint.js](https://github.com/fauna/fauna-shell/blob/v0.0.11/src/commands/default-endpoint.js)_ | ||
_See code: [src/commands/default-endpoint.js](https://github.com/fauna/fauna-shell/blob/v0.1.0/src/commands/default-endpoint.js)_ | ||
@@ -485,3 +480,3 @@ ## `fauna delete-database DBNAME` | ||
_See code: [src/commands/delete-database.js](https://github.com/fauna/fauna-shell/blob/v0.0.11/src/commands/delete-database.js)_ | ||
_See code: [src/commands/delete-database.js](https://github.com/fauna/fauna-shell/blob/v0.1.0/src/commands/delete-database.js)_ | ||
@@ -507,3 +502,3 @@ ## `fauna delete-key KEYNAME` | ||
_See code: [src/commands/delete-key.js](https://github.com/fauna/fauna-shell/blob/v0.0.11/src/commands/delete-key.js)_ | ||
_See code: [src/commands/delete-key.js](https://github.com/fauna/fauna-shell/blob/v0.1.0/src/commands/delete-key.js)_ | ||
@@ -543,3 +538,3 @@ ## `fauna help [COMMAND]` | ||
_See code: [src/commands/list-databases.js](https://github.com/fauna/fauna-shell/blob/v0.0.11/src/commands/list-databases.js)_ | ||
_See code: [src/commands/list-databases.js](https://github.com/fauna/fauna-shell/blob/v0.1.0/src/commands/list-databases.js)_ | ||
@@ -562,3 +557,3 @@ ## `fauna list-endpoints` | ||
_See code: [src/commands/list-endpoints.js](https://github.com/fauna/fauna-shell/blob/v0.0.11/src/commands/list-endpoints.js)_ | ||
_See code: [src/commands/list-endpoints.js](https://github.com/fauna/fauna-shell/blob/v0.1.0/src/commands/list-endpoints.js)_ | ||
@@ -581,3 +576,3 @@ ## `fauna list-keys` | ||
_See code: [src/commands/list-keys.js](https://github.com/fauna/fauna-shell/blob/v0.0.11/src/commands/list-keys.js)_ | ||
_See code: [src/commands/list-keys.js](https://github.com/fauna/fauna-shell/blob/v0.1.0/src/commands/list-keys.js)_ | ||
@@ -603,3 +598,3 @@ ## `fauna shell DBNAME` | ||
_See code: [src/commands/shell.js](https://github.com/fauna/fauna-shell/blob/v0.0.11/src/commands/shell.js)_ | ||
_See code: [src/commands/shell.js](https://github.com/fauna/fauna-shell/blob/v0.1.0/src/commands/shell.js)_ | ||
<!-- commandsstop --> |
@@ -19,3 +19,15 @@ const FaunaCommand = require('../lib/fauna_command.js') | ||
log(`starting shell for database ${dbscope}`); | ||
var defaultEval; | ||
function replEvalPromise(cmd, ctx, filename, cb) { | ||
defaultEval(cmd, ctx, filename, function(error, result) { | ||
if (!error) { | ||
return client.query(result).then(response => cb(error, response)); | ||
} else { | ||
return cb(error, result) | ||
} | ||
}); | ||
} | ||
const r = repl.start({ | ||
@@ -25,22 +37,7 @@ prompt: 'faunadb> ', | ||
}); | ||
defaultEval = r.eval; | ||
r.eval = replEvalPromise; | ||
const query = function (exp) { | ||
client.query(exp) | ||
.then(function(res) { | ||
console.log("\n", res); | ||
r.displayPrompt(); | ||
}) | ||
.catch(function(error) { | ||
console.log("\n", "Error:", error.message); | ||
r.displayPrompt(); | ||
}); | ||
}; | ||
Object.assign(r.context, q); | ||
Object.defineProperty(r.context, 'query', { | ||
configurable: false, | ||
enumerable: true, | ||
value: query | ||
}); | ||
}, dbscope, role); | ||
@@ -47,0 +44,0 @@ } else { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30239
502
580