Hello I am trying to retrieve my data in my database. My data is in this path
https://(MYLINK).firebaseio.com/users/personalID
Inside of this directory I have a lot of data in generated keys. I Want to be able to access them and query through them. But I am having trouble just retrieving a JSON of data.
admin.initializeApp(firebaseConfig)
var db = admin.database();
var users = db.ref('users/B72O-UB2J-51KJ-JUIX')
users.orderByKey().on('value', snapshot =>{
console.log(snapshot.val())
})
Nothing happens when I run this code. Any suggestions ??
I tried to show how my data is structured and stored
My issue was I wasn't importing the correct config to run the administrator app. You can go to your app settings and then they have a config section with all the info.
Related
It's been a while since I used node and express and I was sure that this was possible, but i'm having an issue of figuring it out now.
I have a simple postgres database with sequelize. I am building a back end and don't have a populated database yet. I want to be able to provide fake data to use to build the front end and to test with. Is there a way to populate a database when the node server is started? Maybe by reading a json file into the database?
I know that I could point to this fake data using a setting in the environment file, but I don't see how to read in the data on startup. Is there a way to create a local database, read in the data, and point to that?
You can use fake factory package, I think it can solve your problem.
https://www.npmjs.com/package/faker-factory
FakerJs provides that solution.
import { faker } from '#faker-js/faker';
const randomName = faker.name.findName();
const randomEmail = faker.internet.email();
with the above, you can run a loop for loop to be specific to create
the desired data you may need for your project.
Also, check on the free web-API that provides fake or real data to workon
I'm developing a Xamarin.Forms app which uses an Azure app service with SQL database linked through EasyTables. I've run the samples and successfully tested querying tables etc on the server and enabled offline sync so as a localdb is created.
I've created the store, defined the table & sync'd it, however I want to be able to query it somehow with a where clause - is that possible? Can I add a where clause to the client.GetSyncTable line?
var store = new MobileServiceSQLiteStore("localstore.db");
store.DefineTable<Journey_Stages>();
client.SyncContext.InitializeAsync(store);
tbl_Stages = client.GetSyncTable<Journey_Stages>();
Some of the tables I'm pulling down will grow over time & are linked to individual user profiles, so I only want data which belongs to that user and I don't want to be bringing down masses of data each time, preferably let the server handle that and only bring down what I need on a user by user basis.
Thanks,
Steve
You should add this filtering logic on the server side, so that each user's data isn't exposed to all your other users. See for example this sample if you are using the Node.js backend -- line 17 adds a WHERE clause for the table read query. If you have the .Net backend, similar logic would go in your table controller.
// Configure specific code when the client does a request
// READ - only return records belonging to the authenticated user
table.read(function (context) {
context.query.where({ userId: context.user.id });
return context.execute();
});
I have a Node app set up with Express, Mongoose and MongoDB and as the title says, I am curious if it’s even possible to log where the data is being saved? I’ve tried googling but I haven’t really found anything that answers my question.
The database is hosted on my local machine. No sharding, no extras, just a simple basic database.
This is basically what I want to achieve:
SomeScema = new SomeScema();
SomeSchema.value = 123
SomeSchema.save(function(){
// log where data is saved
return res.status(200);
}
I am currently working on an inventory management software in Node js and MongoDB. I am pretty new to MongoDB, having worked in Oracle and MySQL for most of my projects.
Is it possible to create a separate database schema for every client who uses my software, with each client having access only to his copy of the database schema and collections?
The equivalent of selecting data in Oracle database would be
Select * from User1.table,
Select * from User2.table etc
Also, if it were possible, how would it be implemented using a node js mongo db client like mongoose?
I looked at MongoDB documentation, but it talks mainly about adding users to a database for authorization.
I apologize if it seems like a silly question, but id appreciate it if someone could point me in the right direction for this.
Before starting to invest a lot of time in the development of your project, check out other possible approaches to the scenario that you are trying to build.
I did a quick search on SO and found some additional threads with similar scenarios:
MongoDB Database vs. Collection
MongoDB Web App - Database per User
Additional info about mongoose database creation
Whenever you call the connect method on the mongoose object, you are either connecting to an existing database or you are creating it in case it doesn't already exist.
You could have a function that allows you to pass in a name argument with the name and create databases programmatically:
function createDatabase(name) {
var conn_string = 'mongodb://localhost/';
if (typeof name == 'string') {
conn_string += name;
}else{
return false;
}
mongoose.connect(conn_string);
}
Also, be aware that a database will be created when you first insert a record in a collection of that particular database.
It is not sufficient to only connect to the database, you also have to insert a record.
As per my previous example, you could also pass a schema parameter to the function, tailored to each user's profile and fire an insert statement after you connect to that database.
I am new to web app development, and still learning the basics. I am working on a basic application with nodejs and level db. Every time I restart my web application, the leveldb data store gets recreated, and the data that was stored in it is all gone.
My example code is below:
var level = require ('level');
var db = level('./mydb.db', {createIfMissing : true});
My understanding is that the db will get created only if it is missing.. otherwise the existing db would be used. In my case that is not happening.. what am I doing wrong?
Try the absolute path to the db while opening, it is possible the relative path is changing each time server runs.