1.1.12 • Published 8 years ago

node-postgres-json v1.1.12

Weekly downloads
12
License
MIT
Repository
github
Last release
8 years ago

node-postgres-json

Description:

Node-postgres-json is a light wrap for using the JSON no-sql part of PostgreSQL, which is a great enhanced feature after 9.4. With these functions, users don’t need to know any detail of the postgres JSON operations, and could quickly create collection, insert document, query and create indexes on the keys they want.

Node-postgres-json is based on node-postgres.

Requirements:

A quick sample:

(comming soon)

Quick look of the functions:

All of the functions except setDbUrl and setDbUrl2 are async functions.

setDbUrl (url) Provide the connection string of pg database. which looks like: "postgres://username:password@hostname:port/db"

setDbUrl2 (config) Set up the connection string using object as the argument. postgreConfig = { hostname: 'localhost', port: 5432, username: ‘ezhui', password: '123456', db: 'autotest' };

addCollection( collection, callback ) Create collection in the database. If the collection is already created, it does no harm.

removeCollection( collection, callback ) Remove collection from the database, which also clear all the contained documents and associated indexes.

clearCollection( collection, callback ) Clear all the contained documents in the collection.

isCollectionExist( collection, callback ) Check if the collection is already created.

insert(id, collection, doc, callback ) Insert document into the collection with the provided uuid. The id must be an new one, otherwise the insertion will fail.

update(id, collection, doc, callback) Update an existing document in the collection with provided uuid. If no matched document is found, the update will fail.

upsert(id, collection, doc, callback) If a matched document is found , it will be updated with the new one, otherwise the document will be inserted into the collection

removeById(id, collection, callback) Try to find a matched document and remove it from the collection.

removeByQuery(collection, condition, callback) Try to find all the documents which match the provided condition and remove them from collection.

countByQuery (collection, condition, callback) Return the count of the documents which match the provided condition.

queryById(id, collection,select, callback)

Try to find a matched document and return the selected fields of this document.

query(collection, condition, callback) Try to find a group of matched document and return the selected fields of these documents.

createIndex (collection, field, asText, callback) Create an index on the desired field.

createTSIndex(collection, field, language, callback) Create an full text search index for the desired field.

reIndex(collection, field, asText) Redo the index on the desired field for the collection.

reIndexCollection(collection, callback) Redo the index for the collection using all of the existing indexes.

removeIndex(collection, field, asText) Remove the index from the collection if exists.

1.1.12

8 years ago

1.1.11

8 years ago

1.1.10

8 years ago

1.1.9

8 years ago

1.1.8

8 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago