繁体   English   中英

Couchbase Lite是否真的没有SQL数据库

[英]Does couchbase lite really a no sql database

目前,我正在尝试为我的Java应用程序找到可嵌入的nosql数据库。 我当前的方法是使用榻榻米Lite Java。 我运行了以下示例,并看到了db.sqlite3文件的创建。

            public class Main {
                public static void main(String[] args) {
                    // Enable logging
                    Logger log = Logger.getLogger("app1");
                    log.setLevel(Level.ALL);
                    JavaContext context = new JavaContext();
            // Create a manager
                    Manager manager = null;
                    try {
                        manager = new Manager(context, Manager.DEFAULT_OPTIONS);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
            // Create or open the database named app
                    Database database = null;
                    try {
                        database = manager.getDatabase("app1");
                    } catch (CouchbaseLiteException e) {
                        e.printStackTrace();
                    }
            // The properties that will be saved on the document
                    Map<String, Object> properties = new HashMap<String, Object>();
                    properties.put("title", "Couchbase Mobile");
                    properties.put("sdk", "Java");
            // Create a new document
                    Document document = database.createDocument();
            // Save the document to the database
                    try {
                        document.putProperties(properties);
                    } catch (CouchbaseLiteException e) {
                        e.printStackTrace();
                    }
            // Log the document ID (generated by the database)
            // and properties
                    log.info(String.format("Document ID :: %s", document.getId()));
                    log.info(String.format("Learning %s with %s", (String) document.getProperty("title"), (String) document.getProperty("sdk")));
                    System.out.println(document.toString());
                }
            }

所以我在这里使用nosql数据库吗?

绝对。 评论大部分已经回答了这个问题。

Couchbase Lite不需要任何架构。 它将数据存储为JSON文档(如代码示例所示)。 当前,它使用map / reduce进行索引和查询。 这是一个功能齐全的嵌入式NoSQL数据库(以及更多)。

从编码的角度来看,它的底层实现是无关紧要的。 除了公共API,您不需要知道,也不应依赖。

明确地说,有一个使用ForestDB的Couchbase Lite实现。 目前认为ForestDB不如SQLite成熟,因此它不是默认值。

如果您对实现细节感兴趣,例如一种版本如何使用SQLite,则建议您看一下代码。 您可以在https://github.com/couchbase的各种存储库下找到它

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM