Coder Social home page Coder Social logo

nodejs-domino's Introduction

Node.js driver for NSF

Disclaimer: this is not the official npm module for domino.

Install

npm install domino-nsf

Requirements

From release 0.3.0 it's a source release only, to be able to install, you'll need to follow the instructions in the development section.

Older packages is currently windows only. The binaries has been build for Win32 and tested with Node 8.9.4, 32bit.

The Notes program folder needs to be added to the system PATH.

Linux

If you want to run on Linux, you'll need to build it from source. Check out development section for more..

Usage

Async API

const domino = require('domino-nsf')();

let doc = {
  "FullName":"John Smith",
  "tags":["test","test2"],
  "age":33,
  "Form":"Person"
};

const db = domino.use('database.nsf');

db.get("documentUNID",function(error,document) {
	console.log("document",document);
});

db.insert(doc,function(error,document) {
	// returns the saved document
	console.log("document",document);
});

db.makeResponse(doc,parentDoc,function(err,res) {
	
});

db.view({view:"People",category:""},function(err,view) {
	  console.log("view result",view);
});

db.search("SELECT *", functoin(err,results) {
	//returns the search results
});

db.del("documentUNID",function(error,result) {
	console.log("result",result);
});


// to end session call
domino.termSession(); 

View parameters

{
  view: "the view name",
  max: "number, max entries to get"
  category: "the category to get"
  findByKey: "the key to search by"
  exact: true/false, exact or partial match when using findByKey
}

Synchronous API

const domino = require('domino-nsf')();

// you must run sinitThread before calling any notes api.
domino.sinitThread();
let db = domino.openDatabase('test.nsf');
let note = db.openNotesNote();
note.setItemText('Form','Test');
note.setItemText('Subject','Hello World!');

// save the note
note.updateNote();

// close the note and db
note.close();
db.close();


// terminate thread before exiting
domino.stermThread();

Avaliable methods

Domino object

sinitThread()

init the notes session/thread

stermThread()

terminate the notes thread

createDatabase('server!!path/databasename.nsf')

create a new database, on given serve and path. If path is omitted, localhost is used.
Returns a database object.

openDatabase('server!!path/databasename.nsf')

Opens a database.
Returns a database object.

deleteDatabase('server!!path/databasename.nsf');

Database object

openNotesNote('unid')

Opens a Notes note by UNID.
Returns a note object.

createNotesNote()

Creates a new note in the database.
Returns a Notes object.

getDatabaseName()

Return the database name / title.

close()

Closes the database handle.

Notes object

getItemText('itemName')

returns the items value as a string, returns empty string if item does not exists.

getItemNumber('itemName')

returns the items value as a number

getItemDate('itemName')

return item date value as js date.

getItemValue('itemName')

returns the item value as a text,number,text array or date depending on type.

getItemMime('itemName')

returns the mime item.

hasItem('itemName')

returns true/false if note has item.

getUNID()

returns the note UNID

updateNote()

saves the note to database.

setItemText('itemName','string')

set a string value to an item. If the item exists, it will replace the item value.

setItemDate('itemName', date)

set a Date object value to an item

setItemNumber('itemName,number)

set a number value to an item. If the item exists, it will replace the item value.

setItemValue('itemName', value);

set an value to an item, value can be text,number,text array or js Date object

setItemMime('itemName','header',value);

set an mime item.

appendItemValue('itemName','string')

append a string value to an existing text array.

deleteItem('itemName')

delete an item from a note.
Returns true if item was deleted.

close()

Close the note handle. After calling close, you cannot call any methods on the current Note object.

Development and Contribution

Local Development Windows

To build the addon, you need the

  • Domino C API
  • Nan for Node.js.
  • Microsoft VisualStudio 2015/2017 or by using using Microsoft's windows-build-tools
  • node-gyp

Configuring enviroment for node-gyp build

You must set these environment variables before you build the addon

NOTES_INCLUDE must contain:

  • the C API header files

NOTES_LIB must contain:

  • the path to the Notes C library folder

Linux/Docker

To set up a development enviroment using Docker, you can use this Dockerfile

Configuring and building

node-gyp configure

..and build..

node-gyp build

nodejs-domino's People

Contributors

edm00se avatar nilsisi avatar nthjelme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nodejs-domino's Issues

something error

D:\Lotus\nodejs>node -v
v5.1.0

D:\Lotus\nodejs>node index.js
module.js:450
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: The specified module could not be found.
\\?\D:\Lotus\nodejs\node_modules\domino-nsf\lib\Release\addon.node
    at Error (native)
    at Object.Module._extensions..node (module.js:450:18)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (D:\Lotus\nodejs\node_modules\domino-nsf\index.js:1:80)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)`

Error opening database

var Domino = require('domino-nsf');
var domino = Domino();

var doc = {
"FullName":"John Smith",
"tags":["test","test2"],
"age":33,
"Form":"Person"
};

var db = domino.use({server:"yesme",database:"TWDemo.nsf"});
//let db = domino.openDatabase('TWDemo.nsf');

db.insert(doc,function(error,document) {
// returns the saved document
console.log("document",document);
});

domino.termSession();

2018-09-17 10 27 46

Notes API Link

Hello,

Thanks for such wonderful library.

Yet the link in the Dockerfiles is not functioning, can you please point us to the file?

Thanks!

Search a view

db.view({view:"People",find:"John",findOptions},function(err,result) {
      console.log("find result",result;
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.