any idea how to support timestamps in graphql with juniper?
I'd like to be able to get timestamps from a query/mutation as store them as is in mongodb.
I've been trying to create a custom scalar but haven't succeeded so far.
thank you for your help.
Related
hello I would like to know if it is possible to store data in a database with GraphQL using python without going through mongodb or sql?
Yes. GraphQL doesn't care about the underlying database. You can connect to a csv file, a JSON file, a REST interface whatever.
I work on the following tech stack.
React - for frontend
Node/Express - For Middle Tier
MongoDB - database
Mongoose Driver - to connect the express app to Mongo DB
I use some date picker components to display dates in the UI, which the users can change. I would like to know what is the best way to post dates to the server, and persist in the DB and likewise, how to query for collections with the date formats using mongoose in the express app.
Please suggest consistent and best possible solution.
You have plenty of options for dates. You can stay super lean and deal with them yourself via JS Date object or use momentJS and its tons of plug-ins or go fully functional and light with date-fns.
All of these can be used on the client and on the server. momentJS / date-fns have tons of convenient methods that would save you a lot of time and headaches. date-fns can also be partially imported so you do not need the entire lib if you only want few methods.
Saving the dates ... the recommended way is to use the default ISODate for mongoDB when persisting them (which is mongoDB default anyway). Saving them as strings is not really a recommended thing but you could and you would still be ok as long as you are on version 3.6+ since there and above they added tons of date/string manipulation functions which would save you tons of time if you have to go back and forth from string to date and vise versa. It is best however to deal with dates from the get go.
You should use Date.now() (epoch or utc) both on the server side and client side js. Date fns is a good light-weight js library that works both in node and react js.
I have a basic Nodejs server connected to my ios App and firebase client. I want to fetch data from the database, which is in and system generated alphanumeric format(ex: -ibdUKV6168ded). I obviously cannot input that manually every time theres such entry, also I dont want to fetch it by having an index number of the array. How can I fetch that key.
Plus, Every time such key is generated, i want to read the document present in it.
I am out of ideas.
Any help will be much appreciated.
The database looks like this:
I want to fetch the post keys explicitly. I have a on() event called each time a new post is generated. How can I reference them.
This is solved by the firebase functions. Although, they are in beta, they are a great help. Functions along with Admin SDK provide really great combination to deal with such querying of data, where the values are uniquely identified.
I have an nodejs server running witch show data on a web interface. The data is fetched from a MongoDB using mongoose. The data is added via an node-red application witch is isolated from the rest.
Currently my nodejs server fetches the data every 5 seconds. Is there a way to know if the data in my MongoDB has changed?
Thanks, I hope my question is clear.
I was also looking for something similar to what you are asking for few months back. Few ways which i know to do it are:
1) You can try to use middlewares while inserting your documents in DB. You can then send that new data either after saving it in DB or at the time of insertion only.
2) Refer to this answer which talks about solving your problem using inbuilt functions provided by mongoDb. You can study in deep about them in mongoDb docs.
3) There is also another way to do this which includes listening to changes in log files. As you know everything done in mongo is recorded and logged in files so whenever there is some change in data you can know it from there also. You will have to do the digging by yourself in this method.
Hope it helps!
I want to clone a public api into a mongodb database with nodejs so I can run my own queries and extend the data like I want. My problem is that I want to fetch the newest updates as well. The good thing is that I know when the data will change at the api app approximately.
I thought about something like cronjobs or a setInterval.
In the internet I could find many solutions how to transform a database into a rest api but no vice versa.
Please give me suggestions how to solve this problem.