Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@existdb/node-exist

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@existdb/node-exist - npm Package Compare versions

Comparing version
4.3.2
to
4.4.0
+9
-1
components/collections.js

@@ -21,2 +21,9 @@ // createCollection

// convenience function
// throws an exception if and only if
// the collection exists but cannot be written by the user
function existsAndCanOpen (client, name) {
return client.promisedMethodCall('existsAndCanOpenCollection', [name])
}
module.exports = {

@@ -26,3 +33,4 @@ create,

describe,
read
read,
existsAndCanOpen
}
+1
-1

@@ -58,3 +58,3 @@ {

},
"version": "4.3.2"
"version": "4.4.0"
}

@@ -286,2 +286,15 @@ # node-exist

#### existsAndCanOpen
This function checks if the collection exists and if it does, if the current user can access it.
- returns `true` if the collection exists and the current user can open it
- returns `false` if the collection does not exist
- throws an exception if the collection exists but the current user cannot
access it
```js
db.collections.existsAndCanOpen(collectionPath)
```
### App

@@ -288,0 +301,0 @@

const test = require('tape')
const { connect } = require('../../index')
const connectionOptions = require('../connection')
const asGuest = Object.assign({},
connectionOptions,
{ basic_auth: { user: 'guest', pass: 'guest' } }
)

@@ -66,1 +70,66 @@ test('get collection info', function (t) {

})
test('collection exists and guest cannot open it', function (t) {
const db = connect(asGuest)
db.collections.existsAndCanOpen('/db/system/security')
.then(function () {
t.fail()
t.end()
})
.catch(function (e) {
t.ok(e, '/db/system/security exists and user guest cannot access it')
t.end()
})
})
test('collection exists and guest can open it', function (t) {
const db = connect(asGuest)
db.collections.existsAndCanOpen('/db/apps/dashboard')
.then(function (success) {
t.true(success, '/db/apps/dashboard exists and user guest can access it')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('collection does not exist (guest)', function (t) {
const db = connect(asGuest)
db.collections.existsAndCanOpen('/db/apps/asdf')
.then(function (success) {
t.false(success, '/db/apps/asdf does not exist')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('collection exists and admin can open it', function (t) {
const db = connect(connectionOptions)
db.collections.existsAndCanOpen('/db/system/security')
.then(function (success) {
t.true(success)
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})
test('collection does not exist (admin)', function (t) {
const db = connect(connectionOptions)
db.collections.existsAndCanOpen('/db/apps/asdf')
.then(function (success) {
t.false(success, '/db/apps/asdf does not exist')
t.end()
})
.catch(function (e) {
t.fail(e)
t.end()
})
})