Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 2.0

Basic insert operation.

2 replies [Last post]
  • Login or register to post comments
Tue, 02/05/2013 - 15:26
rkb
Offline
Joined: 11/06/2012
Groups: None

I am trying to populate the database with data and the following .NET code always returns false (fails)

if (client.Store(StoreMode.Add, destination.SKU, destination

Should destination be a JSON serialized object or will Couchbase serialize it? destination.SKU is a string that is unique.

Also the following fails also:

string jsonDestination = JsonConvert.SerializeObject(destination);
if (!client.StoreJson(StoreMode.Add, destination.SKU, jsonDestination))

Ideas as to why these fail?

Top
  • Login or register to post comments
Thu, 02/07/2013 - 01:45
tgrall
Offline
Joined: 09/05/2012
Groups: None

Hello,

Couchbase server does not serialize anything, the server just check of the value is JSON or not, if this is JSON it will type it.

The client API/SDKs are serializing the value to send them into Couchbase server, the default serializer of your platform is used. I can't remember what the default serialization format for C# - I am not a .net person.. yet ;) -, but it is not JSON.

So you have to serialize it to JSON yourself

So you are saying that your Add operation fails:
- what is the exact error message you have?
- If you replace the Add by a Set what is the behavior?

You are positive on the fact that the key does exist already in the DB? (As you know the Add operation will fail if the key is alread present)

Regards

__________________

Tug
@tgrall

Top
  • Login or register to post comments
Thu, 02/07/2013 - 06:14
rkb
Offline
Joined: 11/06/2012
Groups: None

If Couchbase Server doesn't serialize anything then the only correct call would be the last call to 'StoreJson'. But, it also always returns false. There is no error message that is what is in part so frustrating. The method call just returns false. I will try replacing Add with Set and see what happens. I am possitive that the key doesn't already exist in the database. This is a "clean" database. I can confirm this by using the console and seeing that there are no documents in the database.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker