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

Update README with loki> examples #1

Closed
shakthimaan opened this issue May 4, 2016 · 7 comments
Closed

Update README with loki> examples #1

shakthimaan opened this issue May 4, 2016 · 7 comments

Comments

@shakthimaan
Copy link

I was able to start the lokijs-server and run the lokijs-client. But, I am not sure how to use the prompt interface.

I tried:

loki> OP_INSERT "name" "foo"

and the lokijs-server crashed with:

{"collection":"\"name\"","obj":"foo"}
Result is undefined
net.js:625
    throw new TypeError('invalid data');
    ^

TypeError: invalid data
    at Socket.write (net.js:625:11)
    at Socket.<anonymous> (/tmp/lokijs-server/server/server.js:40:12)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:531:20)

If you can update the README.md with few examples, it will helpful. Thanks!

@techfort
Copy link
Owner

techfort commented May 4, 2016

it's been ages since i was working on this but i think the last parameter should be a JSON object (instead of "foo"), e.g. loki> OP_INSERT "name" {"foo":"bar"}

@shakthimaan
Copy link
Author

That exits the server with a different error ("Result is undefined"):

$ node index -p 47134 -f /tmp/lokijs.log
{ port: '47134', filename: '/tmp/lokijs.log' }
ENV NODEJS
Listening to 47134
{"collection":"\"name\"","obj":{"foo":"bar"}}
Result is undefined
net.js:625
    throw new TypeError('invalid data');
    ^

TypeError: invalid data
    at Socket.write (net.js:625:11)
    at Socket.<anonymous> (/tmp/lokijs-server/server/server.js:40:12)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:531:20)

@shakthimaan
Copy link
Author

Any other suggestions on this?

@techfort
Copy link
Owner

@shakthimaan I will try and look at this today - will update later.

@shakthimaan
Copy link
Author

Thanks! I can help in testing the same.

@shakthimaan
Copy link
Author

@techfort Have you had time to debug this?

@rosmirehman
Copy link

rosmirehman commented May 24, 2016

Client (in terminal)

node index
loki> create_collection "collectionname" "objectname"
loki> {"status":"ok","message":"collection created"}
loki> insert "collectionname" {"objectname": "test"}
loki> {"objectname":"test","id":null,"objType":""}
loki> create_collection "collectionname" {"objectname": "test1"}
loki> {"status":"ok","message":"collection created"}
loki>`

Server (in terminal)

node index -p 47134 -f temp.log
{ port: '47134', filename: 'temp.log' }
ENV NODEJS
Listening to 47134
{"collection":""collectionname"","op":6000,"obj":"objectname"}
OP_CREATE_COLLECTION objectname
Result is { status: 'ok', message: 'collection created' }
{"collection":""collectionname"","op":3000,"obj":{"objectname":"test"}}
OP_INSERT { objectname: 'test' }
Result is { objectname: 'test', id: null, objType: '' }
{"collection":""collectionname"","op":6000,"obj":{"objectname":"test1"}}
OP_CREATE_COLLECTION { objectname: 'test1' }
Result is { status: 'ok', message: 'collection created' }

To create collection
$ create_collection "collection_name" "object_name"

To insert
$ insert "collection_name" object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants