小编Les*_*esC的帖子

从MySQL迁移数据到Firebase

我有一个现有的PHP/MySQL应用程序,我试图迁移到AngularJS/Firebase,这只是学习这些新技术的一种方式.

该应用程序在MySQL中有自己的表模式.一个这样的表看起来像:

CREATE TABLE `dictionary` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `word` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `wordmeaning` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `wordlength` int(11) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Run Code Online (Sandbox Code Playgroud)

我的问题是:如何将此表结构及其中的数据从MySQL迁移到Firebase?

我已经尝试通过查询将数据导出为JSON字符串,例如:

SELECT      CONCAT("[",
          GROUP_CONCAT(
               CONCAT("{id:'",id,"',"),
               CONCAT("word:'",word,"',"),
               CONCAT("wordmeaning:'",wordmeaning,"',"),
               CONCAT("wordlength:'",wordlength,"'}")
          )
     ,"]") 
AS json FROM dictionary;
Run Code Online (Sandbox Code Playgroud)

这给出了一个有效的JSON字符串,例如:

[{id:'1',word:'cat',wordmeaning:'a mammal species',wordlength:'3'},
{id:'2',word:'catapult',wordmeaning:'throwing device',wordlength:'8'},
{id:'3',word:'cart',wordmeaning:'something to carry things in',wordlength:'4'}]

我将其保存在一个文件中,并尝试使用导入JSON按钮从Firebase导入文件,我得到了:解析JSON数据时出错.请验证您的输入.(JSON字符串有效.我在http://jsonviewer.stack.hu/查看了它)

关于我可能做错什么的任何想法?我假设Firebase可以处理这些结构及其中的数据.

谢谢.

mysql firebase

13
推荐指数
2
解决办法
2万
查看次数

具有绑定对象的CreateIndex

我有一个包含时间类型字段的集合。我需要能够按年份或月份-年份组合来查询此集合。

我曾尝试在网站上使用索引创建工具,Year(data.expDate)Month(data.expDate)在“条款”中使用诸如此类的方法,但是这种方法不起作用。

这是我的收藏的架构:

type Expense {
  _id: ID!
  expAmount: Float!
  expDate: Time!
  expCategory: Category!
  _ts: Long!
}
Run Code Online (Sandbox Code Playgroud)

我需要能够列出特定年份或特定月份的费用,而不必在我的收藏中创建单独的月份和年份字段。

faunadb

7
推荐指数
1
解决办法
33
查看次数

标签 统计

faunadb ×1

firebase ×1

mysql ×1