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

jive-persistence-mongo is not compatible with the API of the default file persistence, it only accepts objects as data #2

Open
naugtur opened this issue Sep 11, 2014 · 4 comments

Comments

@naugtur
Copy link

naugtur commented Sep 11, 2014

Passing a string as data argument to the save method causes the implementation here to pass the string to collection.update which throws an error.

if jive-persistence-mongo wants to support storing multiple data types, it needs to wrap the incoming data in a simple object.
Otherwise, consistency should be provided to the users by making the simpler storages throw errors in the same cases.

@naugtur
Copy link
Author

naugtur commented Sep 12, 2014

jive-persistence-mongo doesn't have any tests and I don't see how to run jive-sdk tests with mongo persistence.

The find function here has more capabilities than in file and memory persistence.

@rachoac
Copy link

rachoac commented Sep 12, 2014

Regarding tests:

  1. start up mongodb server

  2. run the tests:
    cd jive-persistence-mongo/test
    node run.js

    [2014-09-12 07:28:58.231] [INFO] jive-sdk - ******************
    [2014-09-12 07:28:58.234] [INFO] jive-sdk - MongoDB configured
    [2014-09-12 07:28:58.234] [INFO] jive-sdk - ******************
    [2014-09-12 07:29:00.519] [INFO] jive-sdk - ******************
    [2014-09-12 07:29:00.519] [INFO] jive-sdk - MongoDB configured
    [2014-09-12 07:29:00.520] [INFO] jive-sdk - ******************
    [2014-09-12 07:29:03.228] [INFO] jive-sdk - ******************
    [2014-09-12 07:29:03.229] [INFO] jive-sdk - MongoDB configured
    [2014-09-12 07:29:03.229] [INFO] jive-sdk - ******************
    [2014-09-12 07:29:05.343] [INFO] jive-sdk - ******************
    [2014-09-12 07:29:05.343] [INFO] jive-sdk - MongoDB configured
    [2014-09-12 07:29:05.343] [INFO] jive-sdk - ******************

    4 passing (10s)

@rachoac
Copy link

rachoac commented Sep 12, 2014

File persistence API docs state that it takes data object. The API of both want data.

    /**
     * Save the provided data in a named collection
     * @memberof filePersistence
     * @param {String} collectionID
     * @param {String} key
     * @param {Object} data
     * @returns {Promise} promise
     */
    save : function( collectionID, key, data) {
      ...

See also https://cdn.rawgit.com/jivesoftware/jive-sdk/master/docs/api/filePersistence.html

@naugtur
Copy link
Author

naugtur commented Sep 12, 2014

Thanks. I don't know how I missed the tests :)

So the take away from this is that all persistence implementations should check if data argument is an object. They don't do that right now and the error thrown comes from mongojs

I'll make a pull request on monday with suggestions of error handling.

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

2 participants