Skip to content

Record Cursor

Provide functions to work with kintone Cursor

Currently, there's the only cursor for records.

Constructor

Parameters

Name Type Required Description
params Object (conditional) Required for nodejs
Constructor params.
params.connection Connection (conditional) The connection module of this SDK.
If initializing in a browser environment on kintone, this parameter can be omitted to use session authentication.

Sample code

Init Record Cursor module Javascript

    (function(kintoneJSSDK) {
        'use strict';
        // with connection
        // Define Authentication object
        var kintoneAuth = new kintoneJSSDK.Auth();
        var paramsAuth = {
            username: 'YOUR_USER_NAME',
            password: 'YOUR_PASSWORD'
        };
        kintoneAuth.setPasswordAuth(paramsAuth);

        var paramsConnection = {
            domain: 'YOUR_DOMAIN',
            auth: kintoneAuth
        };
        var connection = new kintoneJSSDK.Connection(paramsConnection);
        // with connection
        var kintoneRC = new kintoneJSSDK.RecordCursor({connection});

        // without connection, module will use session authentication of kintone
        var kintoneRC = new kintoneJSSDK.RecordCursor();

        //...

    }(window.kintoneJSSDK));


Nodejs

    const kintone = require('@kintone/kintone-js-sdk');

    const passwordAuthParam = {
        username: 'YOUR_USERNAME',
        password: 'YOUR_PASSWORD'
    };
    const auth = new kintone.Auth();
    auth.setPasswordAuth(passwordAuthParam);

    const connParam = {
        domain: 'YOUR_DOMAIN',
        auth: auth
    };
    const kintoneConn = new kintone.Connection(connParam);

    const kintoneRC = new kintone.RecordCursor({connection: kintoneConn});

Methods

createCursor(params)

Create a cursor.

Parameters

Name Type Required Description
params Object yes Create cursor params
params.app Integer yes The kintone app ID
params.fields Array<String> (optional) List of field codes you want in the response.
params.query String (optional) The query string that will specify what records will be responded.
params.size Integer (optional) Number of records to retrieve per request.
Default: 100.
Maximum: 500.

Return

Promise

Sample code

Create cursor Javascript
    var rcOption = {
        app: YOUR_APP_ID,
        fields: ['YOUR_FIELD_CODE'],
        query: 'YOUR_QUERY',
        size: YOUR_SIZE
    }

    kintoneRC.createCursor(rcOption).then(function(creatCursorResponse){
        var myCursor = creatCursorResponse;
        console.log('Cursor ID: ' + myCursor.id );
        console.log('Total Count: ' + myCursor.totalCount );
    }).catch((err) => {
        // This SDK return err with KintoneAPIException
        console.log(err);
    });

Nodejs
    const rcOption = {
        app: YOUR_APP_ID,
        fields: ['YOUR_FIELD_CODE'],
        query: 'YOUR_QUERY',
        size: YOUR_SIZE
    }

    kintoneRC.createCursor(rcOption).then(function(creatCursorResponse){
        const myCursor = creatCursorResponse;
        console.log('Cursor ID: ' + myCursor.id );
        console.log('Total Count: ' + myCursor.totalCount );
    }).catch((err) => {
        // This SDK return err with KintoneAPIException
        console.log(err);
    });

getRecords(params)

Get one block of records.

Parameters

Name Type Required Description
params Object yes Get records create
params.id String yes Cursor ID

Return

Promise

Sample code

Get Records Once Javascript
    var rcOption = {
        app: YOUR_APP_ID,
        fields: ['YOUR_FIELD_CODE'],
        query: 'YOUR_QUERY',
        size: YOUR_SIZE
    }

    kintoneRC.createCursor(rcOption).then(function(creatCursorResponse){
        var myCursor = creatCursorResponse;
        return kintoneRC.getRecords({id: myCursor.id})
    }).then(function (getRecordsResponse) {
        console.log('Records result: ');
        console.log(getRecordsResponse);
    }).catch((err) => {
        // This SDK return err with KintoneAPIException
        console.log(err);
    });

Nodejs

    const rcOption = {
        app: YOUR_APP_ID,
        fields: ['YOUR_FIELD_CODE'],
        query: 'YOUR_QUERY',
        size: YOUR_SIZE
    }

    kintoneRC.createCursor(rcOption).then(function(creatCursorResponse){
        const myCursor = creatCursorResponse;
        return kintoneRC.getRecords({id: myCursor.id})
    }).then(function (getRecordsResponse) {
        console.log('Records result: ');
        console.log(getRecordsResponse);
    }).catch((err) => {
        // This SDK return err with KintoneAPIException
        console.log(err);
    });

getAllRecords(params)

Get all records

Parameters

Name Type Required Description
params Object yes Get all records param
params.id String yes Cursor ID

Return

Promise

Sample code

Get All Records Javascript

    var rcOption = {
        app: YOUR_APP_ID,
        fields: ['YOUR_FIELD_CODE'],
        query: 'YOUR_QUERY',
        size: YOUR_SIZE
    }

    kintoneRC.createCursor(rcOption).then(function(creatCursorResponse){
        var myCursor = creatCursorResponse;
        return kintoneRC.getAllRecords({id: myCursor.id})
    }).then(function (getAllRecordsResponse) {
        console.log('All records result: ');
        console.log(getAllRecordsResponse);
    }).catch((err) => {
        // This SDK return err with KintoneAPIException
        console.log(err);
    });

Nodejs

    const rcOption = {
        app: YOUR_APP_ID,
        fields: ['YOUR_FIELD_CODE'],
        query: 'YOUR_QUERY',
        size: YOUR_SIZE
    }

    kintoneRC.createCursor(rcOption).then(function(creatCursorResponse){
        const myCursor = creatCursorResponse;
        return kintoneRC.getAllRecords({id: myCursor.id})
    }).then(function (getAllRecordsResponse) {
        console.log('All records result: ');
        console.log(getAllRecordsResponse);
    }).catch((err) => {
        // This SDK return err with KintoneAPIException
        console.log(err);
    });

deleteCursor(params)

Delete a cursor

Parameters

Name Type Required Description
params Object yes Delete cursor param
params.id String yes Cursor ID

Return

None

Sample code

Delete Cursor Javascript

    var rcOption = {
        app: YOUR_APP_ID,
        fields: ['YOUR_FIELD_CODE'],
        query: 'YOUR_QUERY',
        size: YOUR_SIZE
    }

    kintoneRC.createCursor(rcOption).then(function(creatCursorResponse){
        var myCursor = creatCursorResponse;
        return kintoneRC.deleteCursor({id: myCursor.id})
    }).then(function (getAllRecordsResponse) {
        console.log('Cursor Deleted');
    }).catch((err) => {
        // This SDK return err with KintoneAPIException
        console.log(err);
    });

Nodejs

    const rcOption = {
        app: YOUR_APP_ID,
        fields: ['YOUR_FIELD_CODE'],
        query: 'YOUR_QUERY',
        size: YOUR_SIZE
    }

    kintoneRC.createCursor(rcOption).then(function(creatCursorResponse){
        const myCursor = creatCursorResponse;
        return kintoneRC.deleteCursor({id: myCursor.id})
    }).then(function (getAllRecordsResponse) {
        console.log('Cursor Deleted');
    }).catch((err) => {
        // This SDK return err with KintoneAPIException
        console.log(err);
    });