Я пытаюсь добавить данные в базу данных apigee из текстовых файлов. У меня есть несколько текстовых файлов, содержащих данные книг.Добавление текстового файла данных в базу данных apigee
Я могу добавить один книгу данные по этому коду:
function saveData(){
//Initialize our client
var client = new Usergrid.Client({
orgName:"orgname",
appName:"sandbox"
});
//In our options object we set the type of the entitiy
//and we also set any data that goes along with it
//in this case it's the books title.
var options = {
type:"book",
title:"someTitle",
author:"someAuthor",
newElement:"Value"
};
//Let's create our entity, and display the results
//of the creation in the html element with the id of response
client.createEntity(options, function(error, book){
if(error) {
//error saving book
$("#response").append("There was an error!");
alert("Error");
} else {
var uuid = book.get("uuid");
var author = book.get("author");
var title = book.get("title");
$("#response").append("Book saved! Its uuid on our server is: "+uuid+"<br/>");
$("#response").append("The book you saved was: "+title + "<br/>");
$("#response").append("It's author is: "+author);
alert("Its working");
}
});
}
saveData()
Как получить доступ к .txt файлы и получить данные других книг из JavaScript? Я понимаю, что javascript позволяет добавлять файлы через пользовательский ввод с помощью FileReader(). Есть ли другой способ сделать это?
К сожалению, Ваш вопрос не ясен. Вы пытаетесь прочитать TXT-файл из Node.js? Если это так, ваш вопрос не относится к Apigee. –