GithubHelp home page GithubHelp logo

nativescript-couchbase-plugin's Introduction

npm npm Build Status

NativeScript-Couchbase

The source is now managed at https://github.com/triniwiz/nativescript-plugins

Installation

tns plugin add nativescript-couchbase-plugin

Usage

Note Android min-sdk is 19

import { Couchbase, ConcurrencyMode } from 'nativescript-couchbase-plugin';
const database = new Couchbase('my-database');

const documentId = database.createDocument({
    "firstname": "O",
    "lastname": "Fortune",
    "address": {
        "country": "Trinidad and Tobago"
    },
    "twitter": "https://www.twitter.com/triniwiz"
});

const person = database.getDocument(documentId);


database.updateDocument(documentId, {
    "firstname": "Osei",
    "lastname": "Fortune",
    "twitter": "https://www.twitter.com/triniwiz"
});

// Default concurrency mode is FailOnConflict if you don't pass it
const isDeleted = database.deleteDocument(documentId, ConcurrencyMode.FailOnConflict);

Synchronization with Couchbase Sync Gateway and Couchbase Server

import { Couchbase } from 'nativescript-couchbase-plugin';
const database = new Couchbase('my-database');

const push = database.createPushReplication(
  'ws://sync-gateway-host:4984/my-database'
);
push.setUserNameAndPassword("user","password");
const pull = database.createPullReplication(
  'ws://sync-gateway-host:4984/my-database'
);
pull.setSessionId("SomeId");
pull.setSessionIdAndCookieName("SomeId","SomeCookieName");

push.setContinuous(true);
pull.setContinuous(true);
push.start();
pull.start();

Listening for Changes

database.addDatabaseChangeListener(function(changes) {
  for (var i = 0; i < changes.length; i++) {
    const documentId = changes[i];
    console.log(documentId);
  }
});

Query

const results = database.query({
  select: [], // Leave empty to query for all
  from: 'otherDatabaseName', // Omit or set null to use current db
  where: [{ property: 'firstName', comparison: 'equalTo', value: 'Osei' }],
  order: [{ property: 'firstName', direction: 'desc' }],
  limit: 2
});

Transactions

Using the method inBatch to run group of database operations in a batch/transaction. Use this when performing bulk write operations like multiple inserts/updates; it saves the overhead of multiple database commits, greatly improving performance.

import { Couchbase } from 'nativescript-couchbase-plugin';
const database = new Couchbase('my-database');

database.inBatch(() => {
    const documentId = database.createDocument({
        "firstname": "O",
        "lastname": "Fortune",
        "address": {
            "country": "Trinidad and Tobago"
        }
        "twitter": "https://www.twitter.com/triniwiz"
    });
    
    const person = database.getDocument(documentId);
    
    
    database.updateDocument(documentId, {
        "firstname": "Osei",
        "lastname": "Fortune",
        "twitter": "https://www.twitter.com/triniwiz"
    });
    
    const isDeleted = database.deleteDocument(documentId);
});

API

License

Apache License Version 2.0, January 2004

nativescript-couchbase-plugin's People

Contributors

cfjedimaster avatar elcreator avatar izishere avatar jerbob92 avatar markdoggen avatar peterstaev avatar shiv19 avatar triniwiz avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nativescript-couchbase-plugin's Issues

runtime visualise data from database

I am using this plugin in nativescript vue project. But observing some issues like database is returning 0 results or the query is not returning expected data.
Wondering if we have a tool to visualise data within database during runtime like in browser.

Thank you.

Receiving this error when attempting to use this plugin?

System.err: com.tns.NativeScriptException:
System.err: Calling js method onCreateView failed
System.err:
System.err: TypeError: com.couchbase.lite.DatabaseConfiguration is not a constructor
System.err: File: "file:///data/data/org.nativescript.demo/files/app/tns_modules/nativescript-couchbase-plugin/couchbase-plugin.js, line: 14, column: 23

Code:

import { Couchbase } from 'nativescript-couchbase-plugin';

export class HelloWorldModel extends Observable {
  private database: any;
  private docId: any;

  constructor() {
    super();

    this.database = new Couchbase('my-database');

    console.log('database?');
    console.dir(this.database);

    this.docId = this.database.createDocument({
      foo: "bar"
    });

    console.log('docId', this.docId);
  }

Support for Vanilla JS

I cannot find any documentation or demo for Vanilla JavaScript.
I have NativeScript vanilla JavaScript project, not TypeScript, nor Angular, nor Vue.

how to get count of items from document

Do we have a method that returns count/length of items in any document of database ?

let db = new Couchbase("database");
const data = [ { ...}, {...}, {...}] // lets say 10 records

let documentId = db.createDocument(
{ "data": data },
);

how to get count 10 from documentId ? not seeing any direct method for it. pls suggest.

Support for CBL 2.7

Is it possible to update this plugin to support Couchbase Lite v2.7? There have been a number of key fixes since the currently supported release (2.5.3).

Lack of documentation

Is there any way to chain WHERE in a query?
What does 'logical?' operator and 'between' do?
What is offset property?

Storage of App on devices increase even deleting data

I am using this plugin with my Nativescript application.
This app is heavily using this plugin creating, updating, deleting, querying local databases.
It's okay the storage on device increases when new data is created
However, the storage increased even when data is updated or even deleted.
Hence, the storage of this app on devices is increasing in a very short period.

86806621_789573164866048_6106938123290148864_n

The data size has been increased to a few hundred MB

Is anyone facing this problem too?

Executing DB queries on background thread

I decided to create an issue about this before starting the work.
We're are experiencing UI hangs on DB queries, this makes sense, because NativeScript is all on the UI thread.
We want to make this plugin run the DB queries on a background thread so the UI doesn't hang when we execute these queries and respond with a promise that resolves when the query is completed. NativeScript also does this for HTTP calls, see https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/http/http-request/http-request.android.ts and the corresponding native code https://github.com/NativeScript/tns-core-modules-widgets/blob/master/android/widgets/src/main/java/org/nativescript/widgets/Async.java.

What are your thoughts about this and do you have an idea where to start on this? I tried to look for a way to include native java code in the plugin, but I couldn't figure it out.

ERROR NSErrorWrapper: unable to open database file

Issue

When I insert quickly, this is when this happens.

Which platform(s) does your issue occur on?

  • iOS
  • emulator

Please, provide the following version numbers that your issue occurs with:

{
  "nativescript": {
    "id": "IS_CONFIDENCIAL",
    "tns-android": {
      "version": "6.3.1"
    },
    "tns-ios": {
      "version": "6.3.0"
    }
  },
  "description": "IS_CONFIDENCIAL",
  "license": "SEE LICENSE IN IS_CONFIDENCIAL",
  "repository": "IS_CONFIDENCIAL",
  "scripts": {
    "lint": "tslint \"src/**/*.ts\""
  },
  "dependencies": {
    "@angular/animations": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "@nativescript/theme": "~2.2.1",
    "nativescript-angular": "~8.20.3",
    "nativescript-couchbase-plugin": "^0.9.6",
    "nativescript-datetimepicker": "^1.2.2",
    "nativescript-geolocation": "5.1.0",
    "nativescript-google-maps-sdk": "^2.9.1",
    "nativescript-image-cache-it": "^5.0.0-beta.6",
    "nativescript-iqkeyboardmanager": "^1.5.1",
    "nativescript-material-cardview": "^2.5.4",
    "nativescript-material-ripple": "^3.1.4",
    "nativescript-phone": "^1.4.1",
    "nativescript-ui-listview": "^8.0.1",
    "nativescript-ui-sidedrawer": "~8.0.0",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.4.0",
    "tns-core-modules": "~6.3.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~8.2.0",
    "@ngtools/webpack": "~8.2.0",
    "codelyzer": "~4.5.0",
    "nativescript-dev-webpack": "~1.4.0",
    "node-sass": "^4.7.1",
    "tslint": "~5.19.0",
    "typescript": "~3.5.3"
  },
  "gitHead": "IS_CONFIDENCIAL",
  "readme": "IS_CONFIDENCIAL"
}

app crashes with error JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0x8c

I am using couchbase for persisting data, with large data objects. Now when I am initialising db with data I am getting from server, the app getting crashed with error

A/art: art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0x8c
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]     string: 'b�AUb�AeE�AyE'
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]     in call to NewStringUTF
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]     from java.lang.String com.couchbase.litecore.fleece.FLValue.asString(long)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x73ff3df0 self=0xab9c9008
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   | sysTid=1296 nice=0 cgrp=default sched=0/0 handle=0xf771bbec
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   | state=R schedstat=( 5340666473 664740063 6901 ) utm=482 stm=52 core=4 HZ=100
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   | stack=0xff580000-0xff582000 stackSize=8MB
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   | held mutexes= "mutator lock"(shared held)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #00 pc 000047e0  /system/lib/libbacktrace_libc++.so (_ZN13UnwindCurrent6UnwindEjP8ucontext+23)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #01 pc 00002ff9  /system/lib/libbacktrace_libc++.so (_ZN9Backtrace6UnwindEjP8ucontext+8)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #02 pc 00243079  /system/lib/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiPKcPNS_6mirror9ArtMethodE+68)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #03 pc 00227421  /system/lib/libart.so (_ZNK3art6Thread4DumpERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+144)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #04 pc 000aff6b  /system/lib/libart.so (_ZN3artL8JniAbortEPKcS1_+582)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #05 pc 000b06b1  /system/lib/libart.so (_ZN3art9JniAbortFEPKcS1_z+60)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #06 pc 000b2b3b  /system/lib/libart.so (_ZN3art11ScopedCheck5CheckEbPKcz.constprop.129+882)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #07 pc 000bb5b9  /system/lib/libart.so (_ZN3art8CheckJNI12NewStringUTFEP7_JNIEnvPKc+36)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #08 pc 000d332f  /data/app/com.oes.oesdtmobile-1/lib/arm/libLiteCoreJNI.so (_ZN8litecore3jni9toJStringEP7_JNIEnv7C4Slice+62)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #09 pc 000d48cb  /data/app/com.oes.oesdtmobile-1/lib/arm/libLiteCoreJNI.so (Java_com_couchbase_litecore_fleece_FLValue_asString+58)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   native: #10 pc 001d03ed  /data/dalvik-cache/arm/data@[email protected]@[email protected] (Java_com_couchbase_litecore_fleece_FLValue_asString__J+88)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.couchbase.litecore.fleece.FLValue.asString(Native method)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.couchbase.litecore.fleece.FLValue.asString(FLValue.java:93)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.couchbase.litecore.fleece.FLValue.toObject(FLValue.java:184)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.couchbase.lite.MValueDelegate.toNative(MValueDelegate.java:49)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.couchbase.litecore.fleece.MValue.toNative(MValue.java:105)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.couchbase.litecore.fleece.MValue.asNative(MValue.java:84)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.couchbase.lite.Dictionary.getValue(Dictionary.java:122)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   - locked <0x3422f0ea> (a java.lang.Object)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.couchbase.lite.Dictionary.equals(Dictionary.java:374)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.tns.NativeScriptWeakHashMap.put(NativeScriptWeakHashMap.java:585)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.tns.Runtime.makeInstanceWeakAndCheckIfAlive(Runtime.java:951)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.tns.Runtime.callJSMethodNative(Native method)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.tns.Runtime.callJSMethod(Runtime.java:1070)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.tns.Runtime.callJSMethod(Runtime.java:1050)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.tns.Runtime.callJSMethod(Runtime.java:1042)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.tns.gen.com.google.android.gms.tasks.OnCompleteListener.onComplete(OnCompleteListener.java:16)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.google.android.gms.tasks.zzj.run(unavailable:4)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   - locked <0x17440fdb> (a java.lang.Object)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at android.os.Handler.handleCallback(Handler.java:739)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at android.os.Handler.dispatchMessage(Handler.java:95)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at android.os.Looper.loop(Looper.java:135)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at android.app.ActivityThread.main(ActivityThread.java:5276)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke!(Native method)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke(Method.java:372)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
04-18 12:42:11.525 1296-1296/com.oes.oesdtmobile A/art: art/runtime/check_jni.cc:65] 

I am observing the crash in android device version Android 5.1 Please suggest if there is any workaround for this. I do not have a handle on the data that is to be inserted to the couch db.

How do I tell if a database already exists?

I know that I can get a database, or create one if it doesn't exist with:
var db = new Couchbase('test-database');
How can I tell whether I created a new one or just connected to an existing one?
I want to populate the database when an app is first installed, so I need to know if the database is freshly created.

Need query to get data using offset and limit

hi,
I am trying to create query to get items like in pagination, using offset and limit from one of the document of database.

let db = new Couchbase("database");
const data = [ { timestamp: 111, ...}, {timestamp: 112, ...}, {timestamp: 113, ...}] // lets say 10 records

let documentId = db.createDocument(
{ "data": data },
);

const results = database.query({
select: [],
where: [
{
property: "data.timestamp",
},
],
order: [{ property: "data.timestamp", direction: "desc" }],
limit: 10,
offset: 5
});

But this is not working as expected.


I tried using lodash but this is affecting UI (don't know why)

const documentId = await db.getDocument('data');
items = _.orderBy(documentId.data, data=>data.timestamp, 'desc').splice(offset, count);

deleteDocument missing ConcurrencyMode Param

Hi,

is there any reason for missing the ConcurrencyMode Param in index.d.ts

deleteDocument(documentId: string): any;

should be

deleteDocument(documentId: string, node: ConcurrencyMode): any;

Thank you

Syncing: on iOS push does not work

I tested syncing on Android (version 5.1.1) and iOS (version 12.2) on real device.
On Android, everything works fine, but on iOS pushing data to the server database does not work, though pulling new data from server works.
Here is my sync code in app.js:

const application = require("tns-core-modules/application");

const Couchbase = require('nativescript-couchbase-plugin').Couchbase;

const stock = new Couchbase('stock-database');

const push = stock.createPushReplication(
  'ws://192.168.100.51:4984/stock-database'
);
push.setUserNameAndPassword("sync_gateway","123456");
const pull = stock.createPullReplication(
  'ws://192.168.100.51:4984/stock-database'
);
pull.setSessionId("SomeId");
pull.setSessionIdAndCookieName("SomeId","SomeCookieName");

   
  push.setContinuous(true);
  pull.setContinuous(true);
  push.start();
  pull.start();
  
  
module.exports.stock = stock;


const bestseller = new Couchbase('bestseller-database');

const push2 = bestseller.createPushReplication(
  'ws://192.168.100.51:4984/bestseller-database'
);
push2.setUserNameAndPassword("sync_gateway","123456");
const pull2 = bestseller.createPullReplication(
  'ws://192.168.100.51:4984/bestseller-database'
);
pull2.setSessionId("SomeId");
pull2.setSessionIdAndCookieName("SomeId","SomeCookieName");

   
  push2.setContinuous(true);
  pull2.setContinuous(true);
  push2.start();
  pull2.start();

module.exports.bestseller = bestseller;

application.run({ moduleName: "app-root/app-root" });

Couchbase Server 6.0.0 community edition and Sync Gateway 2.5 community edition are installed and in use on Windows 10 laptop.

Migrate plugin to use new @nativescript/core imports

Make sure to check the demo app(s) for sample usage

Make sure to check the existing issues in this repository

If the demo apps cannot help and there is no issue for your problem, tell us about it

The current version of the plugin works perfectly with NS 7 because of the webpack alt loading modules. But just upgraded a project to NS 8 / Webpack 5 and the plugin no longer works. Webpack fails to compile:

ERROR in ./node_modules/nativescript-couchbase-plugin/couchbase-plugin.ios.js 4:12-51
Module not found: Error: Can't resolve 'tns-core-modules/utils/types' in '/Users/peter/Projects/SwyftCG/node_modules/nativescript-couchbase-plugin'
 @ ./app/shared/db-manager.ts 2:0-92 46:22-31 181:29-53 187:29-53 193:29-53 515:29-53 521:29-53 527:29-53 533:29-53 549:29-53 555:29-53 561:29-53 584:29-53 590:29-53 596:29-53 720:21-33
 @ ./app/ sync .(xml|js|ts|s?css)$ ./shared/db-manager.ts
 @ ./app/__@nativescript_webpack_virtual_entry_typescript__ 3:16-92

ERROR in ./node_modules/nativescript-couchbase-plugin/couchbase-plugin.ios.js 5:9-48
Module not found: Error: Can't resolve 'tns-core-modules/file-system' in '/Users/peter/Projects/SwyftCG/node_modules/nativescript-couchbase-plugin'
 @ ./app/shared/db-manager.ts 2:0-92 46:22-31 181:29-53 187:29-53 193:29-53 515:29-53 521:29-53 527:29-53 533:29-53 549:29-53 555:29-53 561:29-53 584:29-53 590:29-53 596:29-53 720:21-33
 @ ./app/ sync .(xml|js|ts|s?css)$ ./shared/db-manager.ts
 @ ./app/__@nativescript_webpack_virtual_entry_typescript__ 3:16-92

Which platform(s) does your issue occur on?

  • iOS/Android/Both
  • iOS/Android versions
  • emulator or device. What type of device?

Please, provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it)
  • Cross-platform modules: (check the 'version' attribute in the
    node_modules/tns-core-modules/package.json file in your project)
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)
  • Plugin(s): (look for the version numbers in the package.json file of your
    project and paste your dependencies and devDependencies here)

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it.

Is there any code involved?

  • provide a code example to recreate the problem
  • (EVEN BETTER) provide a .zip with application or refer to a repository with application where the problem is reproducible.

GROUP BY

Is there a way to group?

How to use GROUP BY_?
I expected to get result of ...

SELECT *
FROM `travel-sample`
GROUP BY id;
ORDER BY id asc;

I have tried ...

const results = database.query({
  select: [], // Leave empty to query for all
  group: [{ property: 'id' } ],
  order: [{ property: 'id ', direction: 'asc' }]
});

Could not find module 'nativescript-couchbase'

Which platform(s) does your issue occur on?

  • iOS and Android
  • iOS 12.1 and Android 4.4.4
  • emulators and real devices (iPhone 6s and Nexus 4)

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.1.1
  • Cross-platform modules: 5.2.2
  • Runtime(s): 5.1.1 and 5.1.0 (ios/android)
  • Plugin(s):
    "dependencies": {
    "email-validator": "^1.0.7",
    "moment": "^2.18.1",
    "nativescript-couchbase-plugin": "^0.9.0",
    "nativescript-image-cache": "^1.0.6",
    "nativescript-iqkeyboardmanager": "^1.1.0",
    "nativescript-plugin-firebase": "^4.0.5",
    "nativescript-telerik-ui": "^3.0.0-2017.6.22.5",
    "nativescript-theme-core": "~1.0.2",
    "nativescript-timedatepicker": "^1.2.0",
    "tns-core-modules": "^5.2.2",
    "tns-core-modules-snapshot": "3.0.1-5.5.372.32"
    },
    "devDependencies": {
    "nativescript-dev-typescript": "^0.8.0",
    "tns-platform-declarations": "^3.1.0",
    "typescript": "~2.2.1"
    }

Please, tell us how to recreate the issue in as much detail as possible.

I have updated my project and upon discovering nativescript-couchbase has been abandoned, removed it and replaced with nativescript-couchbase-plugin.

Is there any code involved?

The app will build and install on the device but then crashes with the message:

java.lang.RuntimeException: Unable to start activity ComponentInfo{uk.co.wholeschoolmeals.app/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Failed to find module: "nativescript-couchbase", relative to: app/tns_modules/

I have attempted to reset the app by removing the node_modules, hooks and platform folders and running 'npm i'.

Here is a zip of the project: [](https://mtstudios.digitalpigeon.com/msg/GrVr4EDgEemx8gYtQsGbAw/CLWo8uaZoCWCeo7JBz-bDA/file/2942dad0-40e0-11e9-85e8-06e26140e7ff/download# - Whole-School-Meals-v2.zip - Whole-School-Meals-v2.zip)

Thanks in advance,

Tony.

QueryArrayOperator: what about it?

I would like to use the operator QueryArrayOperator 'contains' that is present in common.ts
but it's never used.
I'm trying to query a document with a property which is Array and where I would like to find all documents in array with searched values

Data on syncing

I want to ask how to know if data is finished sync after i called method createPullReplication()

Typo in source code

Line 455 of couchbase-plugin.android.ts

It should be -

nativeQuery = nativeQuery.and(this.setComparision(item));

instead of

nativeQuery = nativeQuery.add(this.setComparision(item));

channels for pull replication

Hi, is there a way to set the channels for pull replication?
Would really appreciate if this method is available.
Thanks :)

QueryComparisonOperator 'in' is not working

Here is my data saved in couchbase db and i want to query this data :

{
    "Name" : "John Doe",
    "Email" : "[email protected]",
    "Skills" : [
        "Software",
        "Programming",
        "Algorithm"
    ],
    "Status": "Active"
}

Please check the source code.

const query = {
            select: [],
            where: [
                {
                    property: 'Skills',
                    comparison: 'in',
                    value: 'Algorithm'
                }
             ],
           from: "myDb"
        }

It is returning empty result !!

createView is not a function

Hello,

when I try to create a view like this:

import { Couchbase } from 'nativescript-couchbase-plugin'

const db = new Couchbase('my-db')

db.createView("myview", "1", function(document, emitter) {
emitter.emit(document._id, document)
})

I'm getting "createView is not a function". How can I create a view with this plugin?

QueryWhereItem - Case insensitive comparation

Hello,

I am using this plugin with my Nativescript application.
I am filtering the Couchbase results by a productName property but I cannot find a way to do this filtering case-insensitive. For example:

this.database.query({ select: [], where: [{ property: 'productName', comparison: 'like', value: '%test%' }] });

Is there a possible way to use like case-insensitive?
Using lower or upper conversions, how can I query like "lower(productName) LIKE %test%"?

Regards,
Pedro

minSdk version error

Trying to install couchbase (0.9.6) but I am getting an error:

Execution failed for task ':app:processDebugMainManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 17 cannot be smaller than version 19 declared in library [com.couchbase.lite:couchbase-lite-android:2.1.0] C:\Users\livro\.gradle\caches\transforms-3\b3b2b581e4ae21fef27c32a2705
269a5\transformed\jetified-couchbase-lite-android-2.1.0\AndroidManifest.xml as the library might be using APIs not available in 17
        Suggestion: use a compatible library with a minSdk of at most 17,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="com.couchbase.lite" to force usage (may lead to runtime failures)

Can't find variable: CBLDatabase Error

Hi.
When I try to run app in IOS (with "tns run ios") I have this error :

JavaScript error: file: node_modules/nativescript-couchbase-plugin/couchbase-plugin.ios.js:15:32: JS ERROR ReferenceError: Can't find variable: CBLDatabase (CoreFoundation) *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: CBLDatabase at Couchbase(file: node_modules/nativescript-couchbase-plugin/couchbase-plugin.ios.js:15:32)

Haven't tried in Android (local env not installed). Any clue how to fix it ?

Thanks

QUERY: WHERE

Is it possible to query a property's property?
Following on from the example you created, if I have a user:

{
    "firstname": "O",
    "lastname": "Fortune",
    "address": {
        "country": "Trinidad and Tobago"
    },
    "twitter": "https://www.twitter.com/triniwiz"
}

How do I query based on the country?

Is it:

where: [{ property: 'address', comparison: 'equalTo', value: 'country: "Trinidad and Tobago"' }],

Or is it:

where: [{ property: 'address.country', comparison: 'equalTo', value: 'Trinidad and Tobago' }],

?

Couchbase Lite Exception -> Can't delete db file while other connections are open

Hi Triniwiz,

First of all ... as always thank you for all you've done for NS !

Then... I'm facing maybe dumb issue...

I'm trying to delete|destroy database content... So I'm calling myDB.destroyDatabase();
Strangely if myDB has already been opened and fulfilled with some data and then I want to destroy data, I get this exception.

--> CouchbaseLiteException{domain='CouchbaseLite', code=16, msg=Can't delete db file while other connections are open}

Then how can I close properly (or force to close) myDB before create new one ?
Or maybe I need to loop over my existing documents to delete them separately ?

Thanks in advance.
Lo.

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.