I am using Couchbase and testing it on my local computer with ASP.NET. I've inserted some data into a sample document and I can read the data using ASP.NET C# Driver for Couchbase. The thing is that when I logged in to the cluster management GUI and look at the document, I get to see lots of characters with no meaning, can't actually see a text representation of the document that I've inserted. With MongoDB, BigCouch, RavenDB the data is plain and simple JOSN document and its easy to update a single document. Am I missing something here?
In my .NET application I have this code:
var client = new CouchbaseClient();
client.Store(StoreMode.Add, "aaa", "sample_data");
client.Dispose();
What I get is in the console when I view the document:
"Y29tcGFyaXNvbl9pZDogMQ=="
This is a binary format, not JSON. Using CouchBase 2.0 beta
In Couchbase Server 2.0, if you store invalid JSON as the value in the key/value pair that you save, you will see a Base64 encoded version of the item you've saved. Since "sample_data" is not a valid JSON document, Couchbase Server treats it like a byte array. When you view the bytes, they're Base64 encoded. Instead, if you change your store method to something like the following:
client.Store(StoreMode.Add, "aaa", "{ \"message\" : \"sample_data\" }");
you'd then see the actual JSON document.
The Getting Started guide for the latest Beta of the Couchbase Client has more information on working with JSON and views with Couchbase Server 2.0 - http://www.couchbase.com/develop/net/next.
It's a bug of Couchbase 2.0 GUI display.Now I use couchbase-server-2.0.0-1723.x86_64 in RHEL 6.0,and create new document with Coubase 2.0 GUI.When I insert under json:
{
"_id": "100",
"name": "Thomas",
"dept": "Sales",
"salary": 5000
}
,then save while list base64 string:
"eyJfaWQiOiIxMDAiLCJuYW1lIjoiVGhvbWFzIiwiZGVwdCI6IlNhbGVzIiwic2FsYXJ5Ijo1MDAwfQ=="
I can follow this post:base64 value display in GUI (Beta 2.0),to fix javascript code in this path:
/opt/couchbase/lib/ns_server/erlang/lib/ns_server-2.0.0r_331_g08fb51b/priv/public/js
Fianlly,Clean the browser cache and login Couchbase 2.0 GUI agian.The documents will display:
"{"_id":"100","name":"Thomas","dept":"Sales","salary":5000}"
It's corrent.
Related
So I am working on an idea for a "dating app" (I know who would have thought) and searching for what kind of Serverless Service I should use for the BE.
Until now I worked with GCP and Firebase, that's why I thought I could also use Firestore as my Database.
The problem is, that I would like to do complex filtering like the following:
.where(“date”, “>=”, today).where(“date”, “<=”, today + 3)
.where(“heightMin”, “>=”, 165).where(“heightMax”, “<=”, 185)
.where(“ageMin”, “>=”, 20).where(“ageMax”, “<=”, 30)
.where(“type”, “==”, “running”).where(“smoker”, “==”, false)
In the Cloud Firestore Documentation, it is stated that such compound queries are not possible. To me this seems like a basic feature, thus I think I might have misinterpreted the documentation. Similar post here Firestore compound query with <= & >=
This is how a document could look like:
{
"date": "2022-03-12",
"time": "18:30:00",
"withFilters": "true",
"smoker": "false",
"heightMin": "165",
"heightMax": "165",
"ageMin": "20",
"ageMax":"30",
"type": "running",
"latitude" : "y",
"longitude : "x",
"participants": "2",
}
I know that I could probably fetch everything and then filter it in the FE but this is suboptimal and costly.
Question:
Is there any way to have such filtering with Firestore even by re-arranging the data structure?
If not, what kind of another service would you recommend? Perhaps AWS Amplify?
Firebase also offers an Algolia Extension that can easily sync your Firestore data with Algolia. Firestore natively does not support full text search or compound queries with many filters but Algolia does.
For example, once you've copied all your existing data in Algolia, you can the query as shown below:
index.search('query', { // <-- requires some query string
filters: 'ageMin > 25 AND heightMin > 175' // ... other constraints
]
}).then(({ hits }) => {
console.log(hits);
});
This might be the easiest and scalable way as your data is present in Firestore and both are managed services. Also also has a client SDK and you can create custom API keys to restrict user access.
MongoDB does support these queries natively but you might have to restructure existing database and migrate the data. You would also have to create indexes to support your queries manually (Algolia creates them automatically unless you want to modify them).
We have created a Mongo DB using Azure cosmos and imported JSON file into a collection. However when we try to access collection from Java api (MongoTemplate) to read imported json, we encounter an exception stating collection not exist in DB.
When we investigated our code more, we have identified the collection name gets truncated. For Ex:- If I have a collection name with "componentTemplates", but the same is displayed with some strange string like "nentTemplates". Because of this our code is not working and application fails to serve the request.
I am working on a project and choosen mongodb for database. On it I have a form with following structure
Here it will save the details in database and will be checked on frontend if form 1 is enabled or not for Home cleaning etc. for this I have planned to save form ids in embedded document but I am not sure if its a good method to save it, I have selected embedded document because we can filter or compare directly. Other way is to save ids comma separated or as json object but then I will not be able to filter it directly and will have to fetch all ids and compare in code.
I have gone through the articles and they recommend it but my concern is, is it good to use embedded document for single value like here ?
Any help or explanation is appreciable.
example
{
id:1,
industry_id:1,
status:1,
forms:[{form_id:1},
{form_id:2}
]
}
Thanks
Same situation like this question, but with current DerbyJS (version 0.6):
Using imported docs from MongoDB in DerbyJS
I have a MongoDB collection with data that was not saved through my
Derby app. I want to query against that and pull it into my Derby app.
Is this still possible?
The accepted answer there links to a dead link. The newest working link would be this: https://github.com/derbyjs/racer/blob/0.3/lib/descriptor/query/README.md
Which refers to the 0.3 branch for Racer (current master version is 0.6).
What I tried
Searching the internets
The naïve way:
var query = model.query('projects-legacy', { public: true });
model.fetch(query, function() {
query.ref('_page.projects');
})
(doesn't work)
A utility was written for this purpose: https://github.com/share/igor
You may need to modify it to only run against a single collection instead of the whole database, but it essentially goes through every document in the database and modifies it with the necessary livedb metadata and creates a default operation for it as well.
In livedb every collection has a corresponding operations collection, for example profiles will have a profiles_ops collection which holds all the operations for the profiles.
You will have to convert the collection to use it with Racer/livedb because of the metadata on the document itself.
An alternative if you dont want to convert is to use traditional AJAX/REST to get the data from your mongo database and then just put it in your local model. This will not be real-time or synced to the server but it will allow you to drive your templates from data that you dont want to convert for some reason.
In the context of ArangoDB, there are different database shells to query data:
arangosh: The JavaScript based console
AQL: Arangodb Query Language, see http://www.arangodb.org/2012/06/20/querying-a-nosql-database-the-elegant-way
MRuby: Embedded Ruby
Although I understand the use of JavaScript and MRuby, I am not sure why I would learn, and where I would use AQL. Is there any information on this? Is the idea to POST AQL directly to the database server?
AQL is ArangoDB's query language. It has a lot of ways to query, filter, sort, limit and modify the result that will be returned. It should be noted that AQL only reads data.
(Update: This answer was targeting an older version of ArangoDB. Since version 2.2, the features have been expanded and data modification on the database is also possible with AQL. For more information on that, visit the documentation link at the end of the answer.)
You cannot store data to the database with AQL.
In contrast to AQL, the Javascript or MRuby can read and store data to the database.
However their querying capabilities are very basic and limited, compared to the possibilities that open up with AQL.
It is possible though to send AQL queries from javascript.
Within the arangosh Javascript shell you would issue an AQL query like this:
arangosh> db._query('FOR user IN example FILTER user.age > 30 RETURN user').toArray()
[
{
_id : "4538791/6308263",
_rev : "6308263",
age : 31,
name : "Musterfrau"
}
]
You can find more info on AQL here:
http://www.arangodb.org/manuals/current/Aql.html